From 20ebf826d23ab105b9aa20adbfed341bc79ce0e1 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Sun, 7 Sep 2008 22:00:06 +0000 Subject: [PATCH] libs/cbi: Catch errors while creating named sections --- libs/cbi/luasrc/cbi.lua | 5 ++++- libs/cbi/luasrc/view/cbi/tblsection.htm | 4 ++++ libs/cbi/luasrc/view/cbi/tsection.htm | 4 ++++ .../admin-full/luasrc/model/cbi/admin_network/network.lua | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index a37e81e87..3e7209781 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -566,7 +566,7 @@ function AbstractSection.create(self, section) local stat if section then - stat = self.map:set(section, nil, self.sectiontype) + stat = section:match("^%w+$") and self.map:set(section, nil, self.sectiontype) else section = self.map:add(self.sectiontype) stat = section @@ -795,6 +795,9 @@ function TypedSection.parse(self, novld) if name and #name > 0 then created = self:create(name) and name + if not created then + self.invalid_cts = true + end end end end diff --git a/libs/cbi/luasrc/view/cbi/tblsection.htm b/libs/cbi/luasrc/view/cbi/tblsection.htm index 49930f848..be7e723f7 100644 --- a/libs/cbi/luasrc/view/cbi/tblsection.htm +++ b/libs/cbi/luasrc/view/cbi/tblsection.htm @@ -113,8 +113,12 @@ end <% if self.anonymous then %> <% else %> + <% if self.invalid_cts then -%>
<% end %> + <% if self.invalid_cts then -%> +
<%:cbi_invalid%>
+ <%- end %> <% end %> diff --git a/libs/cbi/luasrc/view/cbi/tsection.htm b/libs/cbi/luasrc/view/cbi/tsection.htm index 33d5c8e49..70c44aaf6 100644 --- a/libs/cbi/luasrc/view/cbi/tsection.htm +++ b/libs/cbi/luasrc/view/cbi/tsection.htm @@ -45,8 +45,12 @@ $Id$ <% if self.anonymous then -%> <%- else -%> + <% if self.invalid_cts then -%>
<% end %> + <% if self.invalid_cts then -%> +
<%:cbi_invalid%>
+ <%- end %> <%- end %> <%- end %> diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua index fce84fe3f..dab4bb873 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua @@ -33,6 +33,8 @@ end function s.create(self, section) if TypedSection.create(self, section) then created = section + else + self.invalid_cts = true end end -- 2.25.1