diff --git a/src/Composer/Util/ProcessExecutor.php b/src/Composer/Util/ProcessExecutor.php index fe7f06845..82a8cfaa7 100644 --- a/src/Composer/Util/ProcessExecutor.php +++ b/src/Composer/Util/ProcessExecutor.php @@ -180,9 +180,8 @@ class ProcessExecutor return "'".str_replace("'", "'\\''", $argument)."'"; } - if (strpbrk($argument, "\r\n") !== false) { - $argument = preg_replace("/(\r\n|\n|\r)/", ' ', $argument); - } + // New lines break cmd.exe command parsing + $argument = strtr($argument, "\n", ' '); $quote = strpbrk($argument, " \t") !== false; $argument = preg_replace('/(\\\\*)"/', '$1$1\\"', $argument, -1, $dquotes); diff --git a/tests/Composer/Test/Util/ProcessExecutorTest.php b/tests/Composer/Test/Util/ProcessExecutorTest.php index 1ff1a778d..40e098b1a 100644 --- a/tests/Composer/Test/Util/ProcessExecutorTest.php +++ b/tests/Composer/Test/Util/ProcessExecutorTest.php @@ -144,8 +144,8 @@ class ProcessExecutorTest extends TestCase // unix single-quote must be escaped 'unix-sq' => array("a'bc", "a'bc", "'a'\\''bc'"), - // CR LF must be replaced - 'crlf' => array("a\r\nb\nc\rd", '"a b c d"', "'a\r\nb\nc\rd'"), + // new lines must be replaced + 'new lines' => array("a\nb\nc", '"a b c"', "'a\nb\nc'"), // whitespace must be quoted 'ws space' => array('a b c', '"a b c"', "'a b c'"),