Carriage returns are ignored by cmd
parent
0783b043d2
commit
906442117c
|
@ -180,9 +180,8 @@ class ProcessExecutor
|
||||||
return "'".str_replace("'", "'\\''", $argument)."'";
|
return "'".str_replace("'", "'\\''", $argument)."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpbrk($argument, "\r\n") !== false) {
|
// New lines break cmd.exe command parsing
|
||||||
$argument = preg_replace("/(\r\n|\n|\r)/", ' ', $argument);
|
$argument = strtr($argument, "\n", ' ');
|
||||||
}
|
|
||||||
|
|
||||||
$quote = strpbrk($argument, " \t") !== false;
|
$quote = strpbrk($argument, " \t") !== false;
|
||||||
$argument = preg_replace('/(\\\\*)"/', '$1$1\\"', $argument, -1, $dquotes);
|
$argument = preg_replace('/(\\\\*)"/', '$1$1\\"', $argument, -1, $dquotes);
|
||||||
|
|
|
@ -144,8 +144,8 @@ class ProcessExecutorTest extends TestCase
|
||||||
// unix single-quote must be escaped
|
// unix single-quote must be escaped
|
||||||
'unix-sq' => array("a'bc", "a'bc", "'a'\\''bc'"),
|
'unix-sq' => array("a'bc", "a'bc", "'a'\\''bc'"),
|
||||||
|
|
||||||
// CR LF must be replaced
|
// new lines must be replaced
|
||||||
'crlf' => array("a\r\nb\nc\rd", '"a b c d"', "'a\r\nb\nc\rd'"),
|
'new lines' => array("a\nb\nc", '"a b c"', "'a\nb\nc'"),
|
||||||
|
|
||||||
// whitespace <space> must be quoted
|
// whitespace <space> must be quoted
|
||||||
'ws space' => array('a b c', '"a b c"', "'a b c'"),
|
'ws space' => array('a b c', '"a b c"', "'a b c'"),
|
||||||
|
|
Loading…
Reference in New Issue