2 ms·
The main point I was making here was also that there's actually TWO DIFFERENT ESCAPING MECHANISMS at work here. percent encoding AND html entity encoding. If th
by ZenPsycho 8y ago
The main point I was making here was also that there's actually TWO DIFFERENT ESCAPING MECHANISMS at work here. percent encoding AND html entity encoding. If this was a javascript property assignment, I might even need to add in backslash encoding. You're supposed to entity encode the ampersand in a query string as &. If you don't, some text editors will even highlight it as a syntax error for you.
the fact that ampersand was chosen as a query term seperator for URLs, knowing that they're also a special character in html that introduce entitity encodings, seems like it was a bit shortsighted. Browsers won't complain about an unencoded ampersand in a URL, but the the html validators will.
Historically, semicolon ; is also supposed to work as a query term seperator, (in particular, for map coordinates!), and you wouldn't need to entity encode it. but this is such an obscure and historical factoid that it is not consistently implemented, and you can only use it if you know everything handling that url will definitely cope with it correctly.
fun factoid: I once broke Ruby On Rails by convincing DHH using semicolons in query strings was a good idea. Apparently some older versions of safari, and certain proxies broke down when encountering them.