Skip to content

Commit

Permalink
Replace + characters *before* we decode for S3
Browse files Browse the repository at this point in the history
S3 treats `+` characters as spaces, which we try to catch, but we should do it before we decode so that %2B in the url survives intact
  • Loading branch information
mhart committed Aug 12, 2020
1 parent c5d80b1 commit a02cdb3
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/aws4fetch.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class AwsV4Signer {
}
if (this.service === 's3') {
try {
this.encodedPath = decodeURIComponent(this.url.pathname).replace(/\+/g, ' ');
this.encodedPath = decodeURIComponent(this.url.pathname.replace(/\+/g, ' '));
} catch (e) {
this.encodedPath = this.url.pathname;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/aws4fetch.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class AwsV4Signer {
}
if (this.service === 's3') {
try {
this.encodedPath = decodeURIComponent(this.url.pathname).replace(/\+/g, ' ');
this.encodedPath = decodeURIComponent(this.url.pathname.replace(/\+/g, ' '));
} catch (e) {
this.encodedPath = this.url.pathname;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/aws4fetch.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
}
if (this.service === 's3') {
try {
this.encodedPath = decodeURIComponent(this.url.pathname).replace(/\+/g, ' ');
this.encodedPath = decodeURIComponent(this.url.pathname.replace(/\+/g, ' '));
} catch (e) {
this.encodedPath = this.url.pathname;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export class AwsV4Signer {
if (this.service === 's3') {
try {
/** @type {string} */
this.encodedPath = decodeURIComponent(this.url.pathname).replace(/\+/g, ' ')
this.encodedPath = decodeURIComponent(this.url.pathname.replace(/\+/g, ' '))
} catch (e) {
this.encodedPath = this.url.pathname
}
Expand Down
2 changes: 2 additions & 0 deletions test/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ https.globalAgent.maxSockets = 10
'/!\'()*@%21%27%28%29%2A',
'/%2a',
'/%2f%2f',
'/%2b%2b',
'/++',
'/ü%41',
'/ü%41?a=%41ü',
'/۟%41?۟=%41۟',
Expand Down

0 comments on commit a02cdb3

Please sign in to comment.