Bug #31779
Command execution on Windows breaks with special chars in path
Status: | Closed | Start date: | 2011-11-12 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | Bastian Waidelich | % Done: | 0% |
|
Category: | Core | |||
Target version: | - | |||
PHP Version: | 5.3 | Complexity: | ||
Has patch: | Yes | Affected Flow version: | Git master |
Description
Currently, FLOW3 has problems executing shell commands on Windows when the php binary path contains special characters such as backslash, whitespace or round brackets.
Steps to reproduce
Setup FLOW3 on a windows machine (here using ZendServer CE on Windows7 x64) having PHP binary in a folder that contains whitespaces or other special characters.
Configure php binary path in Settings.yaml like this:
core: phpBinaryPathAndFilename: 'C:\Program Files (x86)\Zend\ZendServer\bin\php.exe'
Expected
The correct escaped path should be:
"C:\Program Files (x86)\Zend\ZendServer\bin\php.exe"
Actual
escapeshellcmd() escapes the path as:
C:^\Program Files ^(x86^)^\Zend^\ZendServer^\bin^\php.exe
This leads to error messages like the following (in German, but the problem should be clear) when executing flow3 shell commands (e.g. "flow3 routing:list")
Der Befehl "C:\^Program" ist entweder falsch geschrieben oder konnte nicht gefunden werden.
and prevents the cache compilation to work automatically in Development context.
Solution
The correct escaping is achieved by replacing the escapeshellcmd call by escapeshellarg for Windows OSes.
The attached patch wraps this choice in a new protected function escapeShellCmd inside TYPO3\FLOW3\Core\Bootstrap.
Related issues
History
#1 Updated by Bastian Waidelich over 3 years ago
- Category changed from Command to Core
- Status changed from New to Closed
- Assigned To set to Bastian Waidelich
This is a duplicate of #30040 - will be fixed with the bugfix release 1.0.1. Thanks for the patch though.
#2 Updated by Bastian Waidelich over 3 years ago
Could you please test if https://review.typo3.org/#change,6663 solves the issue for you?
#3 Updated by Alexander Berl over 3 years ago
Yes, solves the problem for me. Thanks :)
#4 Updated by Alexander Berl over 3 years ago
Sorry to re-post this bug, but it seems to have reappeared (or wasn't really fixed yet). I did some more testing with windows command line escaping and found the problem is actually within the escapeshellcmd logic or within windows logic if you want, which requires escaping of special chars ONLY if the string is not quoted (which it must be if it contains whitespaces).
I also posted a comment to the according PHP bug with further information:
https://bugs.php.net/bug.php?id=43261
For the time being I just replaced escapeshellcmd with escapeshellarg and removed the manual quoting.