luci-base: gracefully handle broken firewall forwarding sections
authorJo-Philipp Wich <jo@mein.io>
Thu, 7 Sep 2017 13:29:45 +0000 (15:29 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 17 Oct 2017 15:35:01 +0000 (17:35 +0200)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/luasrc/model/firewall.lua
modules/luci-base/luasrc/view/cbi/firewall_zoneforwards.htm

index 5573a9b..feff085 100644 (file)
@@ -498,11 +498,13 @@ function forwarding.dest(self)
 end
 
 function forwarding.src_zone(self)
 end
 
 function forwarding.src_zone(self)
-       return zone(self:src())
+       local z = zone(self:src())
+       return z.sid and z
 end
 
 function forwarding.dest_zone(self)
 end
 
 function forwarding.dest_zone(self)
-       return zone(self:dest())
+       local z = zone(self:dest())
+       return z.sid and z
 end
 
 
 end
 
 
index 2a433b5..546fd8e 100644 (file)
        &#160;&#8658;&#160;
        <% for _, fwd in ipairs(zone:get_forwardings_by("src")) do
                fz = fwd:dest_zone()
        &#160;&#8658;&#160;
        <% for _, fwd in ipairs(zone:get_forwardings_by("src")) do
                fz = fwd:dest_zone()
-               empty = false %>
+               if fz then
+                       empty = false %>
                <label class="zonebadge" style="background-color:<%=fz:get_color()%>">
                        <strong><%=fz:name()%></strong>
                </label>&#160;
                <label class="zonebadge" style="background-color:<%=fz:get_color()%>">
                        <strong><%=fz:name()%></strong>
                </label>&#160;
-       <% end %>
+       <% end end %>
        <% if empty then %>
                <label class="zonebadge zonebadge-empty">
                        <strong><%=zone:forward():upper()%></strong>
        <% if empty then %>
                <label class="zonebadge zonebadge-empty">
                        <strong><%=zone:forward():upper()%></strong>