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

Tilde should not be escaped as per RFC3986 #117

Conversation

y4m4p
Copy link

@y4m4p y4m4p commented Aug 22, 2024

Hi, first time contributing so sorry if I'm missing anything!

Issue

Heads up

This might be a breaking change, since some server-client setup might rely on ~ being encoded to %7E for whatever reason.
But since this is an RFC offense, the proposed implementation should be the way to go and must be enforced for future usage in web interactive applications and such.

Decoding ~ must remain the same, we just don't want to encode ~.

Details

This PR's change follows other escaping methods in core Ruby, such as CGI.escape, ERB::Util.url_encode (which actually just calls CGI.escapeURIComponent inside).

# URI (current implementation)
irb(main):002:0> require 'uri'
=> true
irb(main):004:0> URI.encode_www_form_component("ruby~test")
=> "ruby%7Etest"

# CGI
irb(main):001:0> require 'cgi'
=> true
irb(main):003:0> CGI.escape("ruby~test")
=> "ruby~test"

# ERB
irb(main):009:0> require 'erb'
=> true
irb(main):012:0> ERB::Util.url_encode("ruby~test")
=> "ruby~test"

# Webrick
# needs webrick gem installed
[3] pry(main)> require 'webrick'
=> true
[4] pry(main)> WEBrick::HTTPUtils.escape_form("ruby~test")
=> "ruby~test"
[5] pry(main)> WEBrick::HTTPUtils.escape("ruby~test")
=> "ruby~test"

@hsbt
Copy link
Member

hsbt commented Sep 6, 2024

I'm closing this by https://bugs.ruby-lang.org/issues/20690#note-2

@hsbt hsbt closed this Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants