olivertappin / phpcs-diff

Detects violations of a defined set of coding standards based on a git diff
MIT License
12 stars 13 forks source link

phpcs-diff fails if the path to PHP_BINARY contains a space character #12

Open richaber opened 7 months ago

richaber commented 7 months ago

If there is a space character in the path to the PHP_BINARY, phpcs-diff will fail. Presumably other unescaped but valid path characters would have the same effect.

Path to the PHP_BINARY in my environment (macOS)...

'/Users/user_name/Library/Application Support/Local/lightning-services/php-8.0.30+0/bin/darwin-arm64/bin/php'

The phpcs-diff failure looks like this...

$ ./vendor/bin/phpcs-diff master
sh: /Users/user_name/Library/Application: No such file or directory
Unable to run phpcs executable.

I am able to resolve this for my environment by using escapeshellarg on PHP_BINARY at line 220 of \PhpcsDiff\PhpcsDiff::runPhpcs() like so...

$exec = escapeshellarg( PHP_BINARY ) . ' ' . $exec;
olivertappin commented 1 month ago

Thanks @richaber, did you want to attempt to raise a pull-request for this? If not, I'll get this change pushed and tagged before the end of the week.