fix(webgui): harden config bool parsing and action error handling

This commit is contained in:
Your Name committed 2026-06-01 09:07:03 +08:00
1 parent 3659d5b7da
commit 37f736c158
10 files changed
+1366 -233

No files matched your search

+7 -1
View File
@@ -38,7 +38,13 @@ function getConfigValue(cfg, key) {
}
function coerceValue(type, raw, isCheckbox) {
if (type === "bool") return !!raw;
if (type === "bool") {
if (typeof raw === "boolean") return raw;
const text = String(raw ?? "").trim().toLowerCase();
if (["1", "true", "yes", "y", "on"].includes(text)) return true;
if (["0", "false", "no", "n", "off", ""].includes(text)) return false;
return !!raw;
}
if (type === "int") {
const n = parseInt(String(raw ?? "0"), 10);
return Number.isFinite(n) ? n : 0;