luci-base: gracefully handle broken firewall forwarding sections

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2017-09-07 15:29:45 +02:00
parent 462779c384
commit 98aacba3ac
2 changed files with 7 additions and 4 deletions

View file

@ -498,11 +498,13 @@ function forwarding.dest(self)
end end
function forwarding.src_zone(self) function forwarding.src_zone(self)
return zone(self:src()) local z = zone(self:src())
return z.sid and z
end end
function forwarding.dest_zone(self) function forwarding.dest_zone(self)
return zone(self:dest()) local z = zone(self:dest())
return z.sid and z
end end

View file

@ -43,11 +43,12 @@
&#160;&#8658;&#160; &#160;&#8658;&#160;
<% for _, fwd in ipairs(zone:get_forwardings_by("src")) do <% for _, fwd in ipairs(zone:get_forwardings_by("src")) do
fz = fwd:dest_zone() fz = fwd:dest_zone()
empty = false %> if fz then
empty = false %>
<label class="zonebadge" style="background-color:<%=fz:get_color()%>"> <label class="zonebadge" style="background-color:<%=fz:get_color()%>">
<strong><%=fz:name()%></strong> <strong><%=fz:name()%></strong>
</label>&#160; </label>&#160;
<% end %> <% end end %>
<% if empty then %> <% if empty then %>
<label class="zonebadge zonebadge-empty"> <label class="zonebadge zonebadge-empty">
<strong><%=zone:forward():upper()%></strong> <strong><%=zone:forward():upper()%></strong>