umpirsky / Twig-Gettext-Extractor

The Twig Gettext Extractor is Poedit friendly tool which extracts translations from twig templates.
MIT License
113 stars 32 forks source link

Escape arguments that have spaces #38

Closed hgezim closed 4 years ago

hgezim commented 8 years ago

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

This PR fixes that

umpirsky commented 8 years ago

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

- $output = system($command, $error);
+ $output = system(escapeshellcmd($command), $error);
hgezim commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

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

umpirsky commented 8 years ago

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