Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Process] Non ASCII characters disappearing during the escapeshellarg #21485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Next Next commit
Avoid to escape non-ascii characters in argument
If the LC_CTYPE is not set at UTF-8, the escapeshellarg() function will remove every non-ascii characters.

As it's usual in europe to have directories with non-ascii chars in their name (ex : ~/Vidéos) the function should throw an exception if we're trying to submit it an argument containing non-ascii param and the LC_CTYPE is not set to use UTF-8
  • Loading branch information
GuillaumeVerdon authored Feb 1, 2017
commit 78620a5968a5f1d073d6df1396d851a30dca9f65
6 changes: 5 additions & 1 deletion 6 src/Symfony/Component/Process/ProcessUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ private function __construct()
*/
public static function escapeArgument($argument)
{

//Fix for PHP bug #43784 escapeshellarg removes % from given string
//Fix for PHP bug #49446 escapeshellarg doesn't work on Windows
//@see https://bugs.php.net/bug.php?id=43784
Expand Down Expand Up @@ -70,7 +71,10 @@ public static function escapeArgument($argument)

return $escapedArgument;
}

// Avoid the disapeareance of non-ascii parameters when LC_CTYPE is not set as UTF-8
if (preg_match('/[^\x20-\x7f]/', $argument) && strpos("UTF-8", setlocale(LC_CTYPE, "0")) === false) {
throw new InvalidArgumentException("argument cannot contains non-ascii characters if the locale LC_CTYPE is not set as UTF-8");
}
return escapeshellarg($argument);
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.