util.openssl: Move quoting and tostring call into escape function
authorKim Alvefur <zash@zash.se>
Wed, 23 Dec 2015 07:42:02 +0000 (08:42 +0100)
committerKim Alvefur <zash@zash.se>
Wed, 23 Dec 2015 07:42:02 +0000 (08:42 +0100)
util/openssl.lua

index 39fe99d6abf3013112259fda1e876e8ed894ee1c..5043e368590601f8fe61c7d1a0fda4df883a0bc3 100644 (file)
@@ -144,7 +144,7 @@ end
 
 do -- Lua to shell calls.
        local function shell_escape(s)
-               return s:gsub("'",[['\'']]);
+               return "'" .. tostring(s):gsub("'",[['\'']]) .. "'";
        end
 
        local function serialize(f,o)
@@ -153,12 +153,12 @@ do -- Lua to shell calls.
                        if type(k) == "string" then
                                t_insert(r, ("-%s"):format(k));
                                if v ~= true then
-                                       t_insert(r, ("'%s'"):format(shell_escape(tostring(v))));
+                                       t_insert(r, shell_escape(v));
                                end
                        end
                end
                for _,v in ipairs(o) do
-                       t_insert(r, ("'%s'"):format(shell_escape(tostring(v))));
+                       t_insert(r, shell_escape(v));
                end
                return t_concat(r, " ");
        end