Diff

util/openssl.lua @ 7021:f436446661ca

util.openssl: Move quoting and tostring call into escape function
author Kim Alvefur <zash@zash.se>
date Wed, 23 Dec 2015 08:42:02 +0100
parent 6902:d2d7ad2563f9
child 7022:3252c107c91a
line wrap: on
line diff
--- a/util/openssl.lua	Wed Dec 23 08:39:22 2015 +0100
+++ b/util/openssl.lua	Wed Dec 23 08:42:02 2015 +0100
@@ -144,7 +144,7 @@
 
 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 @@
 			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