Question at the end!
After years of HTML forms submissions, I realized this for the first time.
Suppose you have an input text in a form, and you type and submit:
There are 2 spaces before the number 2
If the form method=get, it will pass
There+are+2+spaces+before+the+number+2
in the URL, while if the form method=post, it will pass
There are 2 spaces before the number 2
meaning with a single space.
Now, I understand I could use encodeURIElement or whatever, I can JSON it, I can invent a totally new encoding style, base97 for the matter.
But this is just insane! If you REMOVE a space, you LOSE information, it’s not a 1:1 transformation and you will never be able to go back.
I discovered it “by chance” because I was using the string to do a MySQL search with LIKE %whatever% and it was always giving me back 0 elements found (and yes, I am using prepared statements).
This is my question: what is the advantage of NOT ENCODING MULTIPLE SPACES?! I do not see ANY advantage, but if the HTML specifications have been written like this, I hope there is a VALID reason. If the form submits values encoded in a way that is not reversible, then you can NEVER trust it.