Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Incorrect escaping of URLs #138

Closed
bweggersen opened this issue Mar 24, 2017 · 2 comments
Closed

Incorrect escaping of URLs #138

bweggersen opened this issue Mar 24, 2017 · 2 comments
Assignees
Labels

Comments

@bweggersen
Copy link

Hi!

I'm having a problem with URLs not getting escaped correctly. I might have missed something, but it seems like it could be related to a recent change you made to the way you escape URLs: f149ba1#diff-e7632c024955e4a1dc429d3253cbe6bcR584

The smart_escape function used to escape URLs this way:

smart_escape = (string)->
  encodeURIComponent(string).replace(/%3A/g, ":").replace(/%2F/g, "/")

Now, it escapes URLs this way:

smart_escape = (string, unsafe = /([^a-zA-Z0-9_.\-\/:]+)/g)->
  string.replace unsafe, (match)->
  match.split("").map((c)-> "%"+c.charCodeAt(0).toString(16).toUpperCase()).join("")

I have a case where the public_id is Snø_dfom5q. The new escape function produces Sn%F8_dfom5q, while the old, and in this case correct function, produces Sn%C3%B8_dfom5q.

The complete URLs:
http://res.cloudinary.com/hanen/image/upload/Sn%F8_dfom5q.png
http://res.cloudinary.com/hanen/image/upload/Sn%C3%B8_dfom5q.png

If I try to open the new URL (the first one in the list above) I get the following error:

<Error>
<Code>InvalidURI</Code>
<Message>Couldn't parse the specified URI.</Message>
<URI>
/cloudinary_data/res/hanen/image/upload/c_limit,h_200,w_200/Sn%F8_dfom5q.png
</URI>
<RequestId>92E2AA6CF6053C21</RequestId>
<HostId>
T9+GP9naEm0RSFY1aYSn8qGNvmlll7BE97odtnHL2c5du40aR4RQPrTsyvbNOPxh2+fDRLCPxG0=
</HostId>
</Error>

I'm not an expert on URL escaping, so it's hard for me know your thinking behind your recent change and create a PR. But let me know if I can help in any way.

@nadavofi
Copy link
Contributor

Thank you for pointing this out. A fix is on its way.

@nadavofi nadavofi self-assigned this Mar 28, 2017
@nadavofi nadavofi added the bug label Mar 28, 2017
@nadavofi
Copy link
Contributor

@bweggersen, See #140

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants