From aa19e1cfd3aa6f8ce2138b6666ad5e2a4006ea48 Mon Sep 17 00:00:00 2001 From: Tobias Klaus Date: Tue, 16 Feb 2021 09:50:36 +0100 Subject: [PATCH] fixup! Allow for options containing commas --- src/uci.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/uci.lua b/src/uci.lua index f3d0bf9..d31e399 100644 --- a/src/uci.lua +++ b/src/uci.lua @@ -184,13 +184,17 @@ function set_value(module) local target = p["value"] local force = p["force"] - - if (force == "option" and type(target) == "table") or type(target) == "table" and #target == 1 then + originaltype = type(target) + if ( force == "option" and type(target) == "table" ) or type(target) == "table" and #target == 1 and force~='list' then target = table.concat(target, ',') - elseif force == "list" and (type(target) == "string" or type(target) == "number" ) then + elseif force == "list" and ( type(target) ~= "table" or type(target) == "string" ) then target = { target } end + if force == "list" and type(target) ~= "table" then + module:fail_json({msg="original " .. originaltype .. " type is " .. type(target), message=message}) + end + local values = {} if path["option"] then values[path["option"]] = target