Skip to content
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

Do not percent-encode tilde #159

Closed
hakanensari opened this issue May 15, 2012 · 3 comments
Closed

Do not percent-encode tilde #159

hakanensari opened this issue May 15, 2012 · 3 comments

Comments

@hakanensari
Copy link
Contributor

Faraday::Utils.escape is currently forwarding to CGI.escape, which percent-encodes tilde.

Quoting RFC 3986,

For consistency, percent-encoded octets in the ranges of ALPHA
(%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), period (%2E),
underscore (%5F), or tilde (%7E) should not be created by URI
producers and, when found in a URI, should be decoded to their
corresponding unreserved characters by URI normalizers.

It would be awesome to use the percent-encoding method in Addressable::URI or if there's an issue with that, at least replace the current method with:

def escape(component)
  component.to_s.gsub(/([^\w.~-]+)/) do
     '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
  end
end

In case you wonder why I care about this: CGI.escape is messing with Amazon Web Services signatures.

I'd personally throw in Addressable, but I understand there's some ongoing issue with it?

@technoweenie
Copy link
Member

I don't want to depend on another lib if possible (though, having
Faraday work great with Addressable is very important). A fix to
Faraday.escape would be preferable.

@ezkl
Copy link
Contributor

ezkl commented May 15, 2012

Current test suite passes w/ only slight modification to @hakanensari's proposed escape method.

@hakanensari
Copy link
Contributor Author

+1

@mislav mislav closed this as completed in 98ba913 May 28, 2012
mislav added a commit that referenced this issue Feb 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants