diff --git a/src/Symfony/Component/Process/ProcessUtils.php b/src/Symfony/Component/Process/ProcessUtils.php index cde393e8bd..d5f5d9cb08 100644 --- a/src/Symfony/Component/Process/ProcessUtils.php +++ b/src/Symfony/Component/Process/ProcessUtils.php @@ -52,6 +52,9 @@ class ProcessUtils } elseif ('%' === $part) { $escapedArgument .= '^%'; } else { + if ('\\' === substr($part, -1)) { + $part .= '\\'; + } $escapedArgument .= escapeshellarg($part); } } diff --git a/src/Symfony/Component/Process/Tests/ProcessUtilsTest.php b/src/Symfony/Component/Process/Tests/ProcessUtilsTest.php index 603fac53e7..b9e8b0c76a 100644 --- a/src/Symfony/Component/Process/Tests/ProcessUtilsTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessUtilsTest.php @@ -31,6 +31,7 @@ class ProcessUtilsTest extends \PHPUnit_Framework_TestCase array('^%"path"^%', '%path%'), array('"<|>"\\"" "\\""\'f"', '<|>" "\'f'), array('""', ''), + array('"with\trailingbs\\\\"', 'with\trailingbs\\'), ); } @@ -39,6 +40,7 @@ class ProcessUtilsTest extends \PHPUnit_Framework_TestCase array("'%path%'", '%path%'), array("'<|>\" \"'\\''f'", '<|>" "\'f'), array("''", ''), + array("'with\\trailingbs\\'", 'with\trailingbs\\'), ); } }