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>
Thu, 7 May 2020 17:40:49 +0000 (19:40 +0200)
Fixes: #3912
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit ec3a202b69b5bf5785c0785b2ac39efbe5cae2b7)
(cherry picked from commit 6ae1cd8fdbd438574270fa9586f40e223fec40e6)

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

index 916dbb310b166f48dae0885cf9c762086159a15f..6bbd1bc37ce192afccab7446136d43891201ddbb 100644 (file)
@@ -547,9 +547,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 {