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>2022-07-23 01:10:17 +0300
committerJo-Philipp Wich <jo@mein.io>2022-07-23 01:10:17 +0300
commit25dcd0b77c4450b83cd8b8307397e58c34ebfcd1 (patch)
tree16be341a081bb71482d4bdc6a28c8732c9c270a3 /modules
parent2771360108cb3e2011c7c9cb4921a9047ea70910 (diff)
luci-base: uci.js: prevent sending empty uci set operations
Under certain circumstances, a staged uci option value might get unset again before saving the config, leaving an empty section change set behind, causing the save call to send an empty uci set request via rpc, triggering an ubus code 4 (Resource not found) error. In particular this prevented bridge VLANs from getting saved properly. Fixes: #5876 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/uci.js27
1 files changed, 15 insertions, 12 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/uci.js b/modules/luci-base/htdocs/luci-static/resources/uci.js
index 41e902c5fe..a3a0061b66 100644
--- a/modules/luci-base/htdocs/luci-static/resources/uci.js
+++ b/modules/luci-base/htdocs/luci-static/resources/uci.js
@@ -2,6 +2,14 @@
'require rpc';
'require baseclass';
+function isEmpty(object, ignore) {
+ for (var property in object)
+ if (object.hasOwnProperty(property) && property != ignore)
+ return false;
+
+ return true;
+}
+
/**
* @class uci
* @memberof LuCI
@@ -570,16 +578,7 @@ return baseclass.extend(/** @lends LuCI.uci.prototype */ {
/* undelete option */
if (d[conf] && d[conf][sid]) {
- var empty = true;
-
- for (var key in d[conf][sid]) {
- if (key != opt && d[conf][sid].hasOwnProperty(key)) {
- empty = false;
- break;
- }
- }
-
- if (empty)
+ if (isEmpty(d[conf][sid], opt))
delete d[conf][sid];
else
delete d[conf][sid][opt];
@@ -589,8 +588,12 @@ return baseclass.extend(/** @lends LuCI.uci.prototype */ {
}
else {
/* revert any change for to-be-deleted option */
- if (c[conf] && c[conf][sid])
- delete c[conf][sid][opt];
+ if (c[conf] && c[conf][sid]) {
+ if (isEmpty(c[conf][sid], opt))
+ delete c[conf][sid];
+ else
+ delete c[conf][sid][opt];
+ }
/* only delete existing options */
if (v[conf] && v[conf][sid] && v[conf][sid].hasOwnProperty(opt)) {