Re: [whatwg/url] Allow encoding of null values in `application/x-www-form-urlencoded`. (Issue #732)

The key is that the standard only has a single model: a string-to-string(s) multimap. Each entry in this multimap had a string key, and its value is one or more strings.

This model does *not* support:

- The value being null
- The value being a list containing null
- The value being a zero-sized list
- Any special treatment of keys that end in "[]"
- Or anything else, like the value being a number, or boolean, or whatever.

Now. You can build more complicated models on top of the standard's model! You should just do so in a layered fashion, and do so while acknowledging you are going beyond any shared web standard and thus are going to need to do a lot of outreach and consensus building among all consumers/producers you want to interoperate with. In particular, browsers have no need for a more complicated model, and so won't participate. It's easiest if you constrain your model to just one client/server pair, but maybe you want it to expand to "all client/server pairs using a specific library", or even set of collaborating libraries.

Examples of ways you could layer on top of the spec's model include:

- Treating entries with multiple values for the same key as an error, unless the key ends in "[]", in which case you strip the "[]" suffix.
- Treating entries with a single value "null" as your language's null value, and requiring the string "null" to be encoded some other way.
- Treating entries with a single value empty string as your language's null value, and requiring the empty string to be encoded some other way.
- Requiring all values to be JSON-encoded, so you can represent arrays, nulls, booleans, numbers, strings, objects...
- Using suffixes on the keys to denote data types, so e.g. transforming ("foo!bool", ["false"]) into ("foo", false).

Etc. The main idea is that you have a limited space to work with, when you layer on top of the standard's model. So it'll take some work to get people to agree.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/732#issuecomment-1370805923
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/url/issues/732/1370805923@github.com>

Received on Wednesday, 4 January 2023 11:27:03 UTC