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

Support semicolon as URL query separator #114

Closed
pencil opened this issue Apr 10, 2013 · 5 comments
Closed

Support semicolon as URL query separator #114

pencil opened this issue Apr 10, 2013 · 5 comments

Comments

@pencil
Copy link

pencil commented Apr 10, 2013

Addressable does not support semicolon as query separator. Using semicolon instead of the ampersand is recommended by W3C (Wikipedia).

uri = Addressable::URI.parse 'http://www.google.com/search?q=nemo;oe=utf-8'
puts uri.query_values.inspect

Expected output:

{"q"=>"nemo", "oe"=>"utf-8"}

Actual output:

{"q"=>"nemo;oe=utf-8"} 
@sporkmonger
Copy link
Owner

I'm tempted to say, "Let me know when the IETF recommends this." Closing for now, but could possibly be convinced to support it if someone gave actual real-world examples of it being used in the wild on the basis of liberal parsing & Postel's Law.

@sporkmonger
Copy link
Owner

Thought about it more and decided it was more dangerous than I originally was thinking. This would introduce substantial additional ambiguity around ";" character escaping.

sporkmonger added a commit that referenced this issue Apr 10, 2013
@luxflux
Copy link

luxflux commented Apr 11, 2013

I just know one software which does this.... OTRS. It generates URLs like this:
https://otrs.example.org/otrs/index.pl?Action=AgentTicketZoom;TicketID=1337

Thanks for implementing!

@matiasfrndz
Copy link

Section 3.3 in RFC 3986 mentions:

semicolon (";") […] are often used to delimit parameters and parameter values

Also read this answer on stackoverflow:
http://stackoverflow.com/a/2163885

And last but not least the section on path and parameters in the following article:
What Every Developer Should Know About URLs

Seems like support for semicolons is really a must in respect to standards compliance.

@sporkmonger
Copy link
Owner

It's actually a lot more complicated than everyone is making it out to be here. Despite the fact that section 3.3 does talk about the purpose of reserving the ';' character (notably in the path section, not the query section), the justification is essentially that "it's commonly done this way" and I'm hoping that it's abundantly clear to everyone that that particular phrasing is... somewhat inaccurate. Not only that, but in that particular example, the ';' character is being used in a way that is more analogous to the '?' character than the '&' character. There are also significant problems with the approach being advocated. By far the biggest is this one. If we assume the behavior you're asking for:

uri = Addressable::URI.parse("http://example.com/?param1=one;param2=two")
uri.query_values
# => {"param1" => "one", "param2" => "two"}
uri.query_values = uri.query_values.merge("param3" => "three")
# => {"param1" => "one", "param2" => "two", "param3" => "three"}
uri.to_s
# => "http://example.com/?param1=one&param2=two&param3=three"

I hope you can see why this might not be desirable behavior.

Ultimately, the query_values method is attempting to emulate the application/x-www-form-urlencoded content type, poorly specified though it may be. If I implement something other than what's already there, it'll be this.

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