-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
right_awsbase.rb - a '?' character in S3 URL results in bad URL #9
Comments
Oh forgot to mention that I tested this in right_aws 2.0.0 and had the same issue. At least I'm pretty sure I did. I have only been using ruby for three weeks --Tom |
Correction - it is right-awsbase.rb::URLEncode() that is the problem: http://developer.amazonwebservices.com/connect/thread.jspa?threadID=47863&tstart=0 |
So I went looking through the source code for libs3 version 1.4. posted on Amazon. In that code, a function called urlEncode in util.c encodes urls as follows: All characters except a-Z, 0-9 and urlSafe
are encoded. I would guess that this is likely a good way to do it. |
url safe is actually (i think a bullet was added instead of a minus sign) " - _ . ! ~ * ' ( ) / " --Tom |
If fixed the bug in a fork. Now generates urls, etc that work with ?, + and all sorts of weird characters in the s3 key. Note that I did not change how SQS encodes URLs, as I can't test that. |
If you use aws to generate a URL with an expiry for S3:
url = bucket_gen.get("key with ? in it", 30.days)
the resulting URL will not work: There are two problems:
Speculation and guesswork:
I looked at right_awsbase.rb it seems that the problem lies in the amz_escape
eg: add this around line 160
e2 = e2.gsub("?", "%3F")
Or maybe you need to use different encoding for the key from the other arguments.
I have much the same program accessing the same files written in Objective-C. There I (well ASI) encode the S3Key only with lots of encoding. It really can't hurt, except for readability of the resulting URL (so I don't encode for example /)
CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)key, NULL, CFSTR(":?#[]@!$ &'()*+,;="<>%{}|^~`"), NSUTF8StringEncoding);
I tried encoding the ? in the key before passing it in, but that did not work : the %3F then got double coded.
An S3 Key can be any string of utf-8 bytes.
You should likely also test with a string with lots of weird chars, just to be sure...
Thanks, the tools seem to work quite well.
--Tom Andersen
The text was updated successfully, but these errors were encountered: