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>
This commit is contained in:
parent
48a5864f06
commit
2b516423a0
1 changed files with 7 additions and 2 deletions
|
@ -75,11 +75,16 @@ function error404(message)
|
||||||
http.status(404, "Not Found")
|
http.status(404, "Not Found")
|
||||||
message = message or "Not Found"
|
message = message or "Not Found"
|
||||||
|
|
||||||
require("luci.template")
|
local function render()
|
||||||
if not util.copcall(luci.template.render, "error404") then
|
local template = require "luci.template"
|
||||||
|
template.render("error404")
|
||||||
|
end
|
||||||
|
|
||||||
|
if not util.copcall(render) then
|
||||||
http.prepare_content("text/plain")
|
http.prepare_content("text/plain")
|
||||||
http.write(message)
|
http.write(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue