diff options
author | Jo-Philipp Wich <jo@mein.io> | 2018-04-19 11:56:44 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2018-04-19 12:00:13 +0200 |
commit | 172155eb4650e8d81610cbf2e8d358b28003fddc (patch) | |
tree | 19329f82cfbc3dd048c0ce14729f9b4116276af7 /modules/luci-base/luasrc | |
parent | 9b22c9c1e1290f077297b14b835b3b9085b48bde (diff) |
luci-base: properly handle repeated POST parameters
Restore the old luci.http behaviour of converting repeated POST params into
single tables holding all values instead of letting each repeated parameter
overwrite the value of the preceeding one.
Fixes, among other things, the handling of CBI dynamic list values.
Fixes #1752
Fixes 59dea0230 ("luci-base: switch to lucihttp based POST data processing")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/luasrc')
-rw-r--r-- | modules/luci-base/luasrc/http.lua | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/modules/luci-base/luasrc/http.lua b/modules/luci-base/luasrc/http.lua index aa89136072..29edb4470e 100644 --- a/modules/luci-base/luasrc/http.lua +++ b/modules/luci-base/luasrc/http.lua @@ -397,7 +397,15 @@ function mimedecode_message_body(src, msg, file_cb) field.fd:seek(0, "set") end else - msg.params[field.name] = field.value or "" + local val = msg.params[field.name] + + if type(val) == "table" then + val[#val+1] = field.value or "" + elseif val ~= nil then + msg.params[field.name] = { val, field.value or "" } + else + msg.params[field.name] = field.value or "" + end end field = nil @@ -437,7 +445,15 @@ function urldecode_message_body(src, msg) elseif what == parser.NAME then name = lhttp.urldecode(buffer) elseif what == parser.VALUE and name then - msg.params[name] = lhttp.urldecode(buffer) or "" + local val = msg.params[name] + + if type(val) == "table" then + val[#val+1] = lhttp.urldecode(buffer) or "" + elseif val ~= nil then + msg.params[name] = { val, lhttp.urldecode(buffer) or "" } + else + msg.params[name] = lhttp.urldecode(buffer) or "" + end elseif what == parser.ERROR then err = buffer end |