From 24b07f3d954c10b4dd67162e598c6f31471578a5 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Tue, 18 Feb 2020 17:58:43 +0800 Subject: [PATCH] index & s3: handle some url encoding mess --- src/aws/auth.coffee | 3 ++- src/index.coffee | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/aws/auth.coffee b/src/aws/auth.coffee index 6d70ace..40437d9 100644 --- a/src/aws/auth.coffee +++ b/src/aws/auth.coffee @@ -77,7 +77,8 @@ class AwsAuth @headerMap['x-amz-content-sha256'] canonicalURI: -> - encodeURI @url.pathname + # new URL already handles URI encoding for the pathname. No need to repeat here. + @url.pathname canonicalQueryString: -> return "" if not @qsMap diff --git a/src/index.coffee b/src/index.coffee index 3a53f97..b5d6200 100644 --- a/src/index.coffee +++ b/src/index.coffee @@ -113,7 +113,7 @@ handleGET = (req, file) -> # Add content-disposition header to indicate file name inline = util.shouldShowInline headers['content-type'] headers['content-disposition'] = - (if inline then 'inline;' else 'attachment;') + ' filename=' + fileName + (if inline then 'inline;' else 'attachment;') + ' filename*=' + encodeURIComponent fileName # Handle ranged resposes if resp.headers.has 'content-range'