luci-base: uci.js: do not issue malformed uci/delete requests
authorJo-Philipp Wich <jo@mein.io>
Tue, 14 Apr 2020 15:02:42 +0000 (17:02 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 14 Apr 2020 15:03:43 +0000 (17:03 +0200)
Fixes: #3912
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit ec3a202b69b5bf5785c0785b2ac39efbe5cae2b7)

modules/luci-base/htdocs/luci-static/resources/uci.js

index f97cd8e35472f4dcc530b19577bcd40b1c7088b7..e6582b3e2cabe30a6ef328a043262a8356f1deeb 100644 (file)
@@ -553,9 +553,13 @@ return baseclass.extend(/** @lends LuCI.uci.prototype */ {
                                c[conf][sid] = {};
 
                        /* undelete option */
-                       if (d[conf] && d[conf][sid])
+                       if (d[conf] && d[conf][sid]) {
                                d[conf][sid] = d[conf][sid].filter(function(o) { return o !== opt });
 
+                               if (d[conf][sid].length == 0)
+                                       delete d[conf][sid];
+                       }
+
                        c[conf][sid][opt] = val;
                }
                else {