1
0
Fork 0

Fix cmd splitting paths on commas (#10775)

pull/10799/head
John Stevenson 2022-05-12 20:13:55 +01:00 committed by GitHub
parent aeb204bb1d
commit 2837585e47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -490,7 +490,8 @@ class ProcessExecutor
// New lines break cmd.exe command parsing
$argument = strtr($argument, "\n", ' ');
$quote = strpbrk($argument, " \t") !== false;
// In addition to whitespace, commas need quoting to preserve paths
$quote = strpbrk($argument, " \t,") !== false;
$argument = Preg::replace('/(\\\\*)"/', '$1$1\\"', $argument, -1, $dquotes);
$meta = $dquotes || Preg::isMatch('/%[^%]+%|![^!]+!/', $argument);

View File

@ -178,6 +178,9 @@ class ProcessExecutorTest extends TestCase
// no whitespace must not be quoted
'no-ws' => array('abc', 'abc', "'abc'"),
// commas must be quoted
'comma' => array('a,bc', '"a,bc"', "'a,bc'"),
// double-quotes must be backslash-escaped
'dq' => array('a"bc', 'a\^"bc', "'a\"bc'"),