Skip to content
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

Escape arguments that have spaces #38

Closed
wants to merge 1 commit into from

Conversation

hgezim
Copy link

@hgezim hgezim commented May 31, 2016

Passing arguments like --copyright-holder='Zip Recipes Ltd' was not working.

This PR fixes that

Passing arguments like `--copyright-holder='Zip Recipes Ltd'` was not working.

This PR fixes that
@umpirsky
Copy link
Owner

@hgezim Thanks. Can we just escape entire command? Like:

- $output = system($command, $error);
+ $output = system(escapeshellcmd($command), $error);

@hgezim
Copy link
Author

hgezim commented May 31, 2016

@umpirsky Good question! It doesn't seem that escapeshellcmd deals with spaces in arguments, though.

Following characters are preceded by a backslash: #&;|*?~<>^()[]{}$, \x0A and \xFF. ' and " are escaped only if they are not paired.`

However, escapeshellarg() adds single quotes around a string and quotes/escapes any existing single quotes allowing you to pass a string directly to a shell function and having it be treated as a single safe argument.

@umpirsky
Copy link
Owner

umpirsky commented Jun 1, 2016

OK, but this looks a bit like reinventing the wheel. :)

I wold like to use Process component.
It's simple to use and it provides argument escape functionality.

What do you think @hgezim?

@hgezim
Copy link
Author

hgezim commented Jun 2, 2016

@umpirsky That sounds great as long as it won't make symphony itself a dependencies; I'm not using symphony at all.

@umpirsky
Copy link
Owner

umpirsky commented Jun 2, 2016

@hgezim It will make symfony/process a dependency, but I don't see a problem in that. Do you?

@hgezim hgezim closed this Dec 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants