I'm at the end of a long investigation and it's come down to that question
for post_process_urlencoded() in MHD.
MHD currently calls back with ("a&b", "1"). The app I'm working breaks
when it doesn't receive a callback for "b". The http client in this case
(that did the urlencoding) is google-http-java-client 1.23.0.
The client behavior may be questionable, but MHD's behavior doesn't seem
right either. Isn't there some principle, "clients should strive for
conformance, servers should strive for forgiveness".
I've attached a patch to MHD to add a failing test, but without a fix.
As for relevant standards, the W3C[1] is not detailed enough to cover it.
The WhatWG[2] is more specific and allows for empty values and even empty
keys. I'd like to callout uriparser[3], another C library I've patched in
as a work-around. Uriparser documents their handling of these cases well:
* NULL in the value member means there was no '=' in the item text as with
"?abc&def".
* An empty string in the value member means there was '=' in the item as
with "?abc=&def".
[1] https://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1
[2] https://url.spec.whatwg.org/#urlencoded-parsing
[3] https://uriparser.github.io/doc/api/latest/#querystrings
commit aa0534af56d135e1b261d127af09c22015c1ff87
Author: Ethan Tuttle <ethan@ethantuttle.com>
Date: Tue Dec 24 03:50:59 2019 -0800
urlencoding post-processor: add failing tests for keys without values