[erlang-questions] url query string encode/decode

Loïc Hoguin essen@REDACTED
Fri Dec 15 16:25:11 CET 2017


On 12/15/2017 02:38 PM, Roger Lipscombe wrote:
> On 15 December 2017 at 13:22, Loïc Hoguin <essen@REDACTED> wrote:
>> The keys are not unique actually. Browsers will actually send query strings
>> with duplicate keys if there are duplicate names in forms. That's actually
>> how PHP's name[]=value thing works, you get many name[] keys in the query
>> string.
> 
> Yeah; I know they don't have to be unique. My point was that there's
> no *standard* for how non-unique keys should be handled, so it's no
> real surprise when different implementations do different things with
> them.

Implementations do what they want ultimately but there *is* a standard 
as to how this format is parsed and serialized, and it is represented as 
a list of name-value tuples.

   https://url.spec.whatwg.org/#urlencoded-parsing

What applications do after that is up to them of course.

Cowboy unfortunately slightly differs from the standard in that keys 
without a value are represented as {Key, true} instead of {Key, <<>>} 
that I'll have to fix eventually. Maybe in Cowboy 3.0.

-- 
Loïc Hoguin
https://ninenines.eu



More information about the erlang-questions mailing list