lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Am 05.06.2020 um 06:34 schrieb Philippe Verdy:
> I also agree: the URL-encoding of parameters in the query string is
> just a convention
> Also a simple table would break with a query string like "?q=1&q=2&r=3"
> which is also legal:
> - If you represent it as a table it cannot be {"q" = "1"; "q" = "2"; "r"
> = "3"}, which is legal in Lua syntax but as the effect of overriding the
> key "q" with a second assignment so you just get  {"q"="2";"r"="3"}
> - if you use a table of tables, it becomes: {"q" = {"1", "2"}; "r" =
> {"3"}} which preserves all values (note that the MIME encoding typically
> used for POST contents also allow duplicate assignments to the same
> parameter name, so these names are subindexed by a sequence number and
> for POST contents, there are several encodings possible: the posted
> parameters could use many other encodings, including some binary data in
> many supported formats (as indicated by the MIME type, and with the help
> of the transport syntax).

Browsers produce q=1&q=2 for checkboxes in forms.
PHP uses another convention to recognize arrays: ?q[]=1&q[]=2
But it is little known and breaks many scripts that expect only string