Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/openwrt/luci.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-09-11 13:46:59 +0300
committerJo-Philipp Wich <jo@mein.io>2019-09-11 13:46:59 +0300
commiteeced34765e503e473ebc1bcd9aa659f7bbf4e7c (patch)
treefc6b3b9c77b1791bccc802acc691b4ca3d93e03f /applications/luci-app-firewall/htdocs
parent34e73fd983a49e38155a39c2392779cbd6abb67f (diff)
luci-app-firewall: disallow creating zone without name
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'applications/luci-app-firewall/htdocs')
-rw-r--r--applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js
index dc34e84d5e..41840a2268 100644
--- a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js
+++ b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js
@@ -92,11 +92,14 @@ return L.view.extend({
o = s.taboption('general', form.Value, 'name', _('Name'));
o.placeholder = _('Unnamed zone');
o.modalonly = true;
+ o.rmempty = false;
o.datatype = 'and(uciname,maxlength(11))';
o.write = function(section_id, formvalue) {
var cfgvalue = this.cfgvalue(section_id);
- if (cfgvalue != formvalue)
+ if (cfgvalue == null || cfgvalue == '')
+ return uci.set('firewall', section_id, 'name', formvalue);
+ else if (cfgvalue != formvalue)
return firewall.renameZone(cfgvalue, formvalue);
};
@@ -269,7 +272,7 @@ return L.view.extend({
o.cfgvalue = function(section_id) {
var out = (this.option == 'out'),
zone = this.lookupZone(uci.get('firewall', section_id, 'name')),
- fwds = zone.getForwardingsBy(out ? 'src' : 'dest'),
+ fwds = zone ? zone.getForwardingsBy(out ? 'src' : 'dest') : [],
value = [];
for (var i = 0; i < fwds.length; i++)
@@ -280,7 +283,7 @@ return L.view.extend({
o.write = o.remove = function(section_id, formvalue) {
var out = (this.option == 'out'),
zone = this.lookupZone(uci.get('firewall', section_id, 'name')),
- fwds = zone.getForwardingsBy(out ? 'src' : 'dest');
+ fwds = zone ? zone.getForwardingsBy(out ? 'src' : 'dest') : [];
if (formvalue == null)
formvalue = [];