luci-lua-runtime: also search luci.dispatcher scope when looking up values
authorJo-Philipp Wich <jo@mein.io>
Wed, 9 Nov 2022 19:37:54 +0000 (20:37 +0100)
committerJo-Philipp Wich <jo@mein.io>
Wed, 9 Nov 2022 19:37:54 +0000 (20:37 +0100)
Some legacy templates access dispatcher functions such as `build_url()`
without explicit scope, which worked in the old runtime since the template
view namespace was instantiated from the dispatcher.

Ensure that this continues to function in the emulated runtime.

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

index b6b9af0badb8914412eb237a0e59b509b9b11b1e..84fb8bb3383d58c997f3021e0a02cb3f4f0d2068 100644 (file)
@@ -121,7 +121,7 @@ context.viewns = setmetatable({
        elseif key == "resource" then
                return L.config.main.resourcebase
        else
-               return rawget(tbl, key) or _G[key] or L[key]
+               return rawget(tbl, key) or disp[key] or _G[key] or L[key]
        end
 end})