netifd: parse_bool() accepts JSON booleans and numbers

parse_bool() compared its argument with the strings "1", "true", "0"
and "false" only. A service-injected wireless config arrives as JSON, so
a value of true, false, 1 or 0 gave null. wireless.uc then read
"mlo": true of such a wifi-iface as no MLO, and parse_attribute_list()
dropped every boolean attribute that came as JSON.

Accept true and 1 as true, and false and 0 as false. The result for the
UCI strings stays the same.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Felix Fietkau committed 2026-10-08 09:50:39 +02:00
1 parent d9340555b1
commit 762c707df2
1 file changed
+4
@@ -12,9 +12,13 @@ export function parse_bool(val)
switch (val) {
case "1":
case "true":
case true:
case 1:
return true;
case "0":
case "false":
case false:
case 0:
return false;
}
};