svcghost — 2011-08-23T01:28:50-04:00 — #1
Is there any way to prevent an <input> value that is submitted in a GET form from being encoded in the URL? There is just one input value that I want to be decoded, while keeping the others encoded.
dan_grossman — 2011-08-23T03:50:37-04:00 — #2
No. Browsers encode characters that are not allowed to appear in URLs when submitting a form with the GET method... because those characters are not allowed to appear in URLs and the resulting HTTP request for the content at that URL would not be valid.
If your browser did not encode forms, your browser would not work for browsing the web.
felgall — 2011-08-23T04:58:02-04:00 — #3
If you don't want it to be encoded in the URL then you could POST the form instead - that doesn't need to be encoded because it isn't part of a URL.
dan_grossman — 2011-08-23T05:00:14-04:00 — #4
Forms are still encoded when sent by POST. The default encoding is the same as GET (URL encoded -- application/x-www-form-urlencoded).
Forms in HTML documents
Under the default encoding, the browser forms and encodes the key/value pairs exactly the same. If the method is GET, that data string is appended to the URL after a ?. If the method is POST, that string is sent as the request body. The string of data is identical either way.
felgall — 2011-08-23T05:28:38-04:00 — #5
It still doesn't end up encoded in the URL though.
svcghost — 2011-08-24T16:31:57-04:00 — #6
Thanks guys. I decided to use regexp to decode the specific part.
felgall — 2011-08-24T22:41:25-04:00 — #7
Where is it that you are decoding it - if it is on the server and you are running PHP then there is a specific function to decode it - urldecode().
You can't use regexp in HTML and you can't decode it in the actual URL being passed.