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 5573a9b86cae3ed90e4f50b232fc54e8c20a23f5..feff0855c4a5c0600b09a3c429695203b768da30 100644 (file)
@@ -498,11 +498,13 @@ function forwarding.dest(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)
-       return zone(self:dest())
+       local z = zone(self:dest())
+       return z.sid and z
 end
 
 
index 2a433b5696872aa112d96d42be200d10f54d04ab..546fd8e85a53c4edfaeefff9fb3c0f405ffb8a0c 100644 (file)
        &#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;
-       <% end %>
+       <% end end %>
        <% if empty then %>
                <label class="zonebadge zonebadge-empty">
                        <strong><%=zone:forward():upper()%></strong>