From e4689f5cb18a8958eada0b7aebbfc88a863409ce Mon Sep 17 00:00:00 2001 From: Doug Toppin Date: Tue, 17 Jan 2023 16:45:48 -0500 Subject: [PATCH] Resolve #416 demo-ui unicode support (#422) Co-authored-by: Doug Toppin --- source/demo-ui/scripts.js | 4 ++-- source/image-handler/image-handler.ts | 2 +- source/image-handler/image-request.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/demo-ui/scripts.js b/source/demo-ui/scripts.js index 9b60b9381..dfaa7e622 100644 --- a/source/demo-ui/scripts.js +++ b/source/demo-ui/scripts.js @@ -18,7 +18,7 @@ function importOriginalImage() { // Assemble the image request const request = { bucket: bucketName, - key: keyName + key: encodeURIComponent(keyName) } const strRequest = JSON.stringify(request); const encRequest = btoa(strRequest); @@ -77,7 +77,7 @@ function getPreviewImage() { // Set up the request body const request = { bucket: bucketName, - key: keyName, + key: encodeURIComponent(keyName), edits: _edits } if (Object.keys(request.edits).length === 0) { delete request.edits } diff --git a/source/image-handler/image-handler.ts b/source/image-handler/image-handler.ts index 82cd67937..beef93f36 100644 --- a/source/image-handler/image-handler.ts +++ b/source/image-handler/image-handler.ts @@ -443,7 +443,7 @@ export class ImageHandler { alpha: string, sourceImageMetadata: sharp.Metadata ): Promise { - const params = { Bucket: bucket, Key: key }; + const params = { Bucket: bucket, Key: decodeURIComponent(key) }; try { const { width, height } = sourceImageMetadata; const overlayImage: S3.GetObjectOutput = await this.s3Client.getObject(params).promise(); diff --git a/source/image-handler/image-request.ts b/source/image-handler/image-request.ts index f17b25e44..d23350d75 100644 --- a/source/image-handler/image-request.ts +++ b/source/image-handler/image-request.ts @@ -269,7 +269,7 @@ export class ImageRequest { if (requestType === RequestTypes.DEFAULT) { // Decode the image request and return the image key const { key } = this.decodeRequest(event); - return key; + return decodeURIComponent(key); } if (requestType === RequestTypes.THUMBOR || requestType === RequestTypes.CUSTOM) {