luci-base: template.lua: fix nil access in string template error handling
authorJo-Philipp Wich <jo@mein.io>
Fri, 19 Jun 2020 12:49:48 +0000 (14:49 +0200)
committerJo-Philipp Wich <jo@mein.io>
Fri, 19 Jun 2020 12:51:49 +0000 (14:51 +0200)
Template strings have no associated name, which led to an attempt to
concat nil with a string when formatting the error message in case of
exceptions.

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

index ed46f50753ba34f03cea7ab9263d90113d0aa2d5..cd9b73b22bd25fe51bcb6a78daa7297128556920 100644 (file)
@@ -71,7 +71,7 @@ function Template.__init__(self, name, template)
 
                -- If we have no valid template throw error, otherwise cache the template
                if not self.template then
-                       error("Failed to load template '" .. name .. "'.\n" ..
+                       error("Failed to load template '" .. self.name .. "'.\n" ..
                              "Error while parsing template '" .. sourcefile .. "':\n" ..
                              (err or "Unknown syntax error"))
                elseif name then