From 98aacba3ac4b307e8bd2000175cfd66a3b8162c3 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 7 Sep 2017 15:29:45 +0200 Subject: [PATCH] luci-base: gracefully handle broken firewall forwarding sections Signed-off-by: Jo-Philipp Wich --- modules/luci-base/luasrc/model/firewall.lua | 6 ++++-- modules/luci-base/luasrc/view/cbi/firewall_zoneforwards.htm | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/luci-base/luasrc/model/firewall.lua b/modules/luci-base/luasrc/model/firewall.lua index 5573a9b86..feff0855c 100644 --- a/modules/luci-base/luasrc/model/firewall.lua +++ b/modules/luci-base/luasrc/model/firewall.lua @@ -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 diff --git a/modules/luci-base/luasrc/view/cbi/firewall_zoneforwards.htm b/modules/luci-base/luasrc/view/cbi/firewall_zoneforwards.htm index 2a433b569..546fd8e85 100644 --- a/modules/luci-base/luasrc/view/cbi/firewall_zoneforwards.htm +++ b/modules/luci-base/luasrc/view/cbi/firewall_zoneforwards.htm @@ -43,11 +43,12 @@  ⇒  <% for _, fwd in ipairs(zone:get_forwardings_by("src")) do fz = fwd:dest_zone() - empty = false %> + if fz then + empty = false %>   - <% end %> + <% end end %> <% if empty then %>