-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix for invalid v4 signature w/ chunked file that contains non-ASCII characters in key #1632
Conversation
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.
This comment was marked as spam.
Sorry, something went wrong.
Interesting. Thanks for the pull request. Some follow up questions:
|
@@ -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.
This comment was marked as spam.
Sorry, something went wrong.
Hi, |
Thanks for the update. We'll need to abide by the Apache 2.0 license, since the code you added is from the AWS JS SDK which uses this license. I'm not sure what specific requirements that license has for attribution - I haven't looked yet. So, remaining here:
|
Regarding the Manual testing:
key : 'filename' key : function(id) {
return uploader.getName(id);
} Regarding the license... do you think that's better to rewrite the code not using the aws code ? |
Not necessarily. We just need to abide by the terms of the license. Most likely attribution is required. If so, I can be sure that this is respected in the appropriate location. Other manual testing will need to completed, but I can take care of that as a final step once the other items above are covered. |
Now i'm on vacation for two weeks. is it a problem if i write the tests as soon as i return to work? |
No problem. I'll try to take care of the license and manual testing myself in that timeframe. |
Here i'm, back from vacation. |
I think some tests that target the new functions and the old one that was changed, specifically, are needed. Those should go in test/unit/s3/util.js. Then I would write or update at least one test in test/unit/s3/chunked-uploads.js to ensure non-ascii characters are properly encoded for all requests sent by the library. I will follow-up with manual tests before merge. |
Sorry for the late feedback. I've wrote tests for the modified function and pushed to my fork |
Great work, thanks. I'll run a few tests locally and then release this as 5.11.9 if all looks well. If this hasn't progressed by next week, feel free to ping me as it may have dropped off my radar. |
Since some of this code was borrowed from the AWS SDK-JS project, we are (as far as I can tell) bound by the Apache 2.0 license, thus we must do the following:
But quite frankly, I'm not sure. Does this fall under "fair use" since you're only using a couple of regexps? Does "fair use" even apply to code? Maybe @lsegal can weigh in on this, since he contributed the referenced code to the AWS repo. |
Well... as the function is just a string replace with some extras i can rewrite it in many ways to get the same result |
No need to re-write - just a question of attribution, which will be easily solved. |
Ownership for the code falls directly to AWS, so my response may not be authoritative in any way (since I'm not an Amazon lawyer, or any kind of lawyer frankly). That said, this code looks fine to me personally. I would recommend that if you borrowed a function simply call that out in the code comments for the functions. A simple |
Thanks so much for your prompt response @lsegal. It looks like only a line here and there was borrowed, so a comment linking to the reference/inspiration seems reasonable to me. If it ever turns out we are in violation of the license in any sense (or of any license), I will make appropriate adjustments ASAP when prompted. |
@rnicholus I think that's great. I would only add that those functions were basically taken wholesale in their entirety (having touched those util functions quite a few times I immediately recognized the code when I saw the PR diff), so it's not quite "a line here and there". They were modified slightly (removed comments and added some callouts to |
@rnicholus , sure i can. |
… under Apache 2.0 license
Comment added |
This will be released with 5.11.9. I may include one or two more cases in 5.11.9. That has yet to be determined. |
Brief description of the changes
Took the code from aws js sdk and ported to fineuploader replacing calls to encodeURIComponent for the key value. and removed an erroneous escape
What browsers and operating systems have you tested these changes on?
All browsers
Are all automated tests passing? [REQUIRED]
yes
Is this pull request against develop or some other non-master branch?
yes
Fixes #1630