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)
This commit is contained in:
Jo-Philipp Wich 2020-04-14 17:02:42 +02:00
parent d0daa2c47b
commit 6ae1cd8fdb

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