luci-lua-runtime: ensure proper forwarding of route arguments to cbi action
authorJo-Philipp Wich <jo@mein.io>
Wed, 26 Oct 2022 07:49:02 +0000 (09:49 +0200)
committerJo-Philipp Wich <jo@mein.io>
Wed, 26 Oct 2022 13:12:17 +0000 (15:12 +0200)
Ensure that the optional cbi() `config` argument is set to an empty table
if unspecified to ensure that the static call argument array is exactly
two elements long, otherwise call arguments are shifted and the invoked
method might not receive the expected parameter.

This fixes, among others, the dispatching of `arcombine()` targets.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-lua-runtime/luasrc/dispatcher.lua

index 8889853b982a22599a8e6a7df638fabde01d407d..7859ba17a3e53008fc24ab0456c09c42a4574e51 100644 (file)
@@ -392,7 +392,7 @@ function cbi(model, config)
                ["type"] = "call",
                ["module"] = "luci.dispatcher",
                ["function"] = "invoke_cbi_action",
-               ["parameters"] = { model, config },
+               ["parameters"] = { model, config or {} },
                ["post"] = {
                        ["cbi.submit"] = true
                }