Skip to content

Commit

Permalink
[Process] Fix #9160 : escaping an argument with a trailing backslash …
Browse files Browse the repository at this point in the history
…on windows fails
  • Loading branch information
romainneutron committed Mar 12, 2014
1 parent 2c55a2d commit 10e903a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Symfony/Component/Process/ProcessUtils.php
Expand Up @@ -52,6 +52,9 @@ public static function escapeArgument($argument)
} elseif ('%' === $part) {
$escapedArgument .= '^%';
} else {
if ('\\' === substr($part, -1)) {
$part .= '\\';
}
$escapedArgument .= escapeshellarg($part);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Process/Tests/ProcessUtilsTest.php
Expand Up @@ -31,6 +31,7 @@ public function dataArguments()
array('^%"path"^%', '%path%'),
array('"<|>"\\"" "\\""\'f"', '<|>" "\'f'),
array('""', ''),
array('"with\trailingbs\\\\"', 'with\trailingbs\\'),
);
}

Expand All @@ -39,6 +40,7 @@ public function dataArguments()
array("'%path%'", '%path%'),
array("'<|>\" \"'\\''f'", '<|>" "\'f'),
array("''", ''),
array("'with\\trailingbs\\'", 'with\trailingbs\\'),
);
}
}

0 comments on commit 10e903a

Please sign in to comment.