bug #10429 [2.3][Process] Fix #9160 : escaping an argument with a trailing backslash on windows fails (romainneutron)

This PR was merged into the 2.3 branch.

Discussion
----------

[2.3][Process] Fix #9160 : escaping an argument with a trailing backslash on windows fails

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #9160
| License       | MIT

Commits
-------

10e903a [Process] Fix #9160 : escaping an argument with a trailing backslash on windows fails
This commit is contained in:
Fabien Potencier 2014-03-12 19:29:14 +01:00
commit 0b1b1738df
2 changed files with 5 additions and 0 deletions

View File

@ -52,6 +52,9 @@ class ProcessUtils
} elseif ('%' === $part) {
$escapedArgument .= '^%';
} else {
if ('\\' === substr($part, -1)) {
$part .= '\\';
}
$escapedArgument .= escapeshellarg($part);
}
}

View File

@ -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\\'),
);
}
}