1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Fixing url encoding issues #272

URLs that contain special characters (got media, face or directory) got parsed the wrong way, this commit fixes it.
This commit is contained in:
Patrik J. Braun 2021-05-15 10:33:43 +02:00
parent ea3506c388
commit 355df1d022
5 changed files with 16 additions and 17 deletions

View File

@ -13,6 +13,6 @@ export class Person implements PersonDTO {
}
public static getThumbnailUrl(that: PersonDTO): string {
return Utils.concatUrls(Config.Client.urlBase, '/api/person/', that.name, '/thumbnail');
return Utils.concatUrls(Config.Client.urlBase, '/api/person/', encodeURIComponent(that.name), '/thumbnail');
}
}

View File

@ -18,13 +18,13 @@ export class FaceComponent implements OnInit, OnDestroy {
@Input() person: PersonDTO;
@Input() size: number;
thumbnail: PersonThumbnail = null;
public thumbnail: PersonThumbnail = null;
public searchQueryDTOstr: string;
constructor(private thumbnailService: ThumbnailManagerService,
private sanitizer: DomSanitizer,
private faceService: FacesService,
public authenticationService: AuthenticationService) {
public authenticationService: AuthenticationService) {
}
@ -43,11 +43,10 @@ export class FaceComponent implements OnInit, OnDestroy {
}
getSanitizedThUrl(): SafeStyle {
return this.sanitizer.bypassSecurityTrustStyle('url(' +
encodeURI(this.thumbnail.Src)
.replace(/\(/g, '%28')
.replace(/'/g, '%27')
.replace(/\)/g, '%29') + ')');
return this.sanitizer.bypassSecurityTrustStyle('url(' + this.thumbnail.Src
.replace(/\(/g, '%28')
.replace(/'/g, '%27')
.replace(/\)/g, '%29') + ')');
}
ngOnDestroy(): void {

View File

@ -24,12 +24,12 @@ export class MediaIcon {
}
getRelativePath(): string {
return Utils.concatUrls(this.media.directory.path,
return encodeURI(Utils.concatUrls(this.media.directory.path,
this.media.directory.name,
this.media.name)
this.media.name))
// do not escape all urls with encodeURIComponent because that make the URL ugly and not needed
// do not escape before concatUrls as that would make prevent optimizations
.replace(new RegExp('%', 'g'), '%25') // order important
// .replace(new RegExp('%', 'g'), '%25') // order important
.replace(new RegExp('#', 'g'), '%23')
.replace(new RegExp('\\$', 'g'), '%24');
}

View File

@ -31,11 +31,10 @@ export class GalleryDirectoryComponent implements OnInit, OnDestroy {
}
getSanitizedThUrl(): SafeStyle {
return this.sanitizer.bypassSecurityTrustStyle('url(' +
encodeURI(this.thumbnail.Src)
.replace(/\(/g, '%28')
.replace(/'/g, '%27')
.replace(/\)/g, '%29') + ')');
return this.sanitizer.bypassSecurityTrustStyle('url(' + this.thumbnail.Src
.replace(/\(/g, '%28')
.replace(/'/g, '%27')
.replace(/\)/g, '%29') + ')');
}
// TODO: implement scroll

View File

@ -94,7 +94,8 @@ export class GalleryService {
}
try {
const cw = await this.networkService.getJson<ContentWrapperWithError>('/gallery/content/' + directoryName, params);
const cw = await this.networkService.getJson<ContentWrapperWithError>('/gallery/content/' +
encodeURIComponent(directoryName), params);
if (!cw || cw.notModified === true) {