Always use a temp file when passing input to shell commands to avoid quoting issues.

The "echo 'input' | command" apprach doesn't work reliably for input containing "\n".
Fixed giving up the pipe approach and just using a temp file always.
This commit is contained in:
Yevgen Muntyan 2012-04-22 22:38:13 +02:00
parent c9bd552d06
commit 5403d30d73

View File

@ -248,18 +248,6 @@ make_cmd (const char *base_cmd_line,
if (!input_len)
return g_strdup (base_cmd_line);
if (input_len < 2048)
{
char *quoted;
quoted = g_shell_quote (input);
g_return_val_if_fail (quoted != NULL, NULL);
cmd_line = g_strdup_printf ("echo -n %s | ( %s )", quoted, base_cmd_line);
g_free (quoted);
}
else
{
char *tmp_file = save_temp (input, input_len);
if (tmp_file)
@ -268,7 +256,6 @@ make_cmd (const char *base_cmd_line,
base_cmd_line, tmp_file, tmp_file);
g_free (tmp_file);
}
}
return cmd_line;
}