Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Fix for invalid v4 signature w/ chunked file that contains non-ASCII characters in key #1632

Merged
merged 8 commits into from
Sep 22, 2016
3 changes: 2 additions & 1 deletion client/js/s3/request-signer.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ qq.s3.RequestSigner = function(o) {
if (queryParamIdx > 0) {
path = endOfUri.substr(0, queryParamIdx);
}
return escape("/" + decodeURIComponent(path));
return "/" + path;
//return escape("/" + decodeURIComponent(path));

This comment was marked as spam.

},

getEncodedHashedPayload: function(body) {
Expand Down
6 changes: 4 additions & 2 deletions client/js/s3/s3.xhr.upload.handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,10 @@ qq.s3.XhrUploadHandler = function(spec, proxy) {
},

urlSafe: function(id) {
var encodedKey = encodeURIComponent(handler.getThirdPartyFileId(id));
return encodedKey.replace(/%2F/g, "/");
var encodedKey = handler.getThirdPartyFileId(id);
return qq.s3.util.uriEscapePath(encodedKey);
// var encodedKey = encodeURIComponent(handler.getThirdPartyFileId(id));

This comment was marked as spam.

// return encodedKey.replace(/%2F/g, "/");
}
},

Expand Down
21 changes: 21 additions & 0 deletions client/js/s3/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,27 @@ qq.s3.util = qq.s3.util || (function() {

// replace percent-encoded spaces with a "+"
return percentEncoded.replace(/%20/g, "+");
},
/**
* Escapes url part as for AWS requirements
*/
uriEscape: function(string) {
var output = encodeURIComponent(string);
output = output.replace(/[^A-Za-z0-9_.~\-%]+/g, escape);
output = output.replace(/[*]/g, function(ch) {
return "%" + ch.charCodeAt(0).toString(16).toUpperCase();
});
return output;
},
/**
* Escapes a path as for AWS requirement
*/
uriEscapePath: function(path) {
var parts = [];
qq.each(path.split("/"), function(idx, item) {
parts.push(qq.s3.util.uriEscape(item));
});
return parts.join("/");
}
};
}());