-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
\Symfony\Component\Process\Process::escapeArgument as a service class #41447
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
Comments
It's not possible to correctly escape arguments in a portable way. That's why the API of the Process component doesn't provide a way to escape arguments, and also why you should never do so. Instead, use prepared command lines. |
@nicolas-grekas do you mean the syntax passing an array to the Process constructor ? If yes, that's not a solution here, as it does not support using shell features like piping the output of a command to another one (which is done here). If no, you will need to provide more details about your solution. |
See #34848 |
Apparently, the doc has it wrong. See symfony/symfony-docs#15387 |
Closing as explained. TLDR: never escape argument, always use prepared command lines (for the exact same reasons as escaping SQL arguments in a no-go, as it's neither reliable/portable.) |
Description
Extract
\Symfony\Component\Process\Process::escapeArgument
to a separate service class, so that external classes can make use of the shell argument escaping.Commands like
\Symfony\Component\Process\Process::fromShellCommandline
accept raw input, but sometimes the client wants to make sure the arguments passed to that method are actually escaped. Or is argument binding the only preferred way to achieve this?Example
The text was updated successfully, but these errors were encountered: