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:
parent
c9bd552d06
commit
5403d30d73
@ -248,26 +248,13 @@ make_cmd (const char *base_cmd_line,
|
||||
if (!input_len)
|
||||
return g_strdup (base_cmd_line);
|
||||
|
||||
if (input_len < 2048)
|
||||
char *tmp_file = save_temp (input, input_len);
|
||||
|
||||
if (tmp_file)
|
||||
{
|
||||
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)
|
||||
{
|
||||
cmd_line = g_strdup_printf ("( %s ) < '%s' ; rm '%s'",
|
||||
base_cmd_line, tmp_file, tmp_file);
|
||||
g_free (tmp_file);
|
||||
}
|
||||
cmd_line = g_strdup_printf ("( %s ) < '%s' ; rm '%s'",
|
||||
base_cmd_line, tmp_file, tmp_file);
|
||||
g_free (tmp_file);
|
||||
}
|
||||
|
||||
return cmd_line;
|
||||
|
Loading…
x
Reference in New Issue
Block a user