summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-04-10 12:03:15 +0200
committerJo-Philipp Wich <jo@mein.io>2018-04-10 12:03:15 +0200
commit2b516423a0eb14882344faf0de46215e34c5c248 (patch)
treee462e132c297a48b7dc11240e4eaad098c43b32a /modules/luci-base
parent48a5864f06528e5e454f6e009ec863122f997415 (diff)
luci-base: fix rendering of 404 HTML error template
This 404 error template rendering has been broken for a long time due to bad function environment level in luci.template when invoking the rendering from the toplevel dispatcher context. Fix this issue by adding a local function indirection, essentially adding an additional stack frame. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base')
-rw-r--r--modules/luci-base/luasrc/dispatcher.lua9
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/luci-base/luasrc/dispatcher.lua b/modules/luci-base/luasrc/dispatcher.lua
index fc497ca9f3..5fc2b80e71 100644
--- a/modules/luci-base/luasrc/dispatcher.lua
+++ b/modules/luci-base/luasrc/dispatcher.lua
@@ -75,11 +75,16 @@ function error404(message)
http.status(404, "Not Found")
message = message or "Not Found"
- require("luci.template")
- if not util.copcall(luci.template.render, "error404") then
+ local function render()
+ local template = require "luci.template"
+ template.render("error404")
+ end
+
+ if not util.copcall(render) then
http.prepare_content("text/plain")
http.write(message)
end
+
return false
end