From: Joshua Vlantis Date: Mon, 4 May 2026 05:20:08 +0000 (+0200) Subject: luci-app-strongswan-swanctl: fix Tunnel/Remote modal crash X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=e639d481ebdf561db39a512a94d181207d80aa00;p=openwrt-luci.git luci-app-strongswan-swanctl: fix Tunnel/Remote modal crash Opening the Tunnel (or Remote) configuration modal threw TypeError: Cannot convert undefined or null to object and the modal never opened. The crypto_proposal MultiValue fields on remote and tunnel sections showed the "Please create a Proposal first" placeholder only when no crypto_proposal sections existed at all. When proposals existed but none matched the required type (IKE/non-ESP for remote, ESP for tunnel), the inner forEach added no choices, leaving keylist empty. An empty keylist makes form.MultiValue.transformChoices() return null, which is then passed to ui.Dropdown. Because typeof null === 'object', the null check in UIDropdown.__init__ does not replace it, and the subsequent Object.keys(this.choices) call throws. Filter the sections list by is_esp before the length check so the placeholder is shown whenever no proposals of the required type exist. Fixes: https://github.com/openwrt/luci/issues/8606 Signed-off-by: Joshua Vlantis --- diff --git a/applications/luci-app-strongswan-swanctl/htdocs/luci-static/resources/view/strongswan-swanctl/swanctl.js b/applications/luci-app-strongswan-swanctl/htdocs/luci-static/resources/view/strongswan-swanctl/swanctl.js index 73fcb4cc82..aea22185f4 100644 --- a/applications/luci-app-strongswan-swanctl/htdocs/luci-static/resources/view/strongswan-swanctl/swanctl.js +++ b/applications/luci-app-strongswan-swanctl/htdocs/luci-static/resources/view/strongswan-swanctl/swanctl.js @@ -121,14 +121,14 @@ return view.extend({ this.keylist = []; this.vallist = []; - var sections = uci.sections('ipsec', 'crypto_proposal'); + var sections = uci.sections('ipsec', 'crypto_proposal').filter(function (section) { + return section.is_esp != '1'; + }); if (sections.length == 0) { this.value('', _('Please create a Proposal first')); } else { sections.forEach(L.bind(function (section) { - if (section.is_esp != '1') { - this.value(section['.name']); - } + this.value(section['.name']); }, this)); } @@ -318,14 +318,14 @@ return view.extend({ this.keylist = []; this.vallist = []; - var sections = uci.sections('ipsec', 'crypto_proposal'); + var sections = uci.sections('ipsec', 'crypto_proposal').filter(function (section) { + return section.is_esp == '1'; + }); if (sections.length == 0) { this.value('', _('Please create an ESP Proposal first')); } else { sections.forEach(L.bind(function (section) { - if (section.is_esp == '1') { - this.value(section['.name']); - } + this.value(section['.name']); }, this)); }