luci-base: uci.js: do not issue malformed uci/delete requests

Fixes: #3912
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit ec3a202b69b5bf5785c0785b2ac39efbe5cae2b7)
(cherry picked from commit 6ae1cd8fdb)
This commit is contained in:
Jo-Philipp Wich 2020-04-14 17:02:42 +02:00
parent 96e3a03d8e
commit 30c1e5b260

View 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 {