views:

91

answers:

1

ampersand vs semicolon

Although it is strongly recommended (W3C source, via Wikipedia) for web servers to support semicolon as a separator of URL query items (in addition to ampersand), it does not seem to be generally followed.

For example, compare

        http://www.google.com/search?q=nemo&oe=utf-8

        http://www.google.com/search?q=nemo;oe=utf-8

results. (In the latter case, semicolon is, or was at the time of writing this text, treated as ordinary string character, as if the url was: http://www.google.com/search?q=nemo%3Boe=utf-8)

Although the first URL parsing library i tried, behaves well:

>>> from urlparse import urlparse, query_qs
>>> url = 'http://www.google.com/search?q=nemo;oe=utf-8'
>>> parse_qs(urlparse(url).query)
{'q': ['nemo'], 'oe': ['utf-8']}

What is the current status of accepting semicolon as a separator, and what are potential issues or some interesting notes? (from both server and client point of view)

+2  A: 

As long as your HTTP server, and your server-side application, accept semicolons as separators, you should be good to go. I cannot see any drawbacks. As you said, the W3C spec is on your side:

We recommend that HTTP server implementors, and in particular, CGI implementors support the use of ";" in place of "&" to save authors the trouble of escaping "&" characters in this manner.

Daniel Vassallo
mykhal
Daniel Vassallo
@[Daniel Vassallo] i mean, generally. btw, i was implicitly addressing exactly the same W3C quotation you are mentioning in your answer, which therefore is not satisfying for me.. never mind :)
mykhal
@mykhal: Yes, I was aware of that :) ... Nevertheless, I don't think there are any issues on the development side (apart from having to check that your framework and web server support semicolons)... Interesting question, btw :)
Daniel Vassallo