Changeset

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 (2015-12-23)
parents 7020:6ab9c691c4c6
children 7022:3252c107c91a
files util/openssl.lua
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
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