Bug #31779

Command execution on Windows breaks with special chars in path

Added by Alexander Berl about 10 years ago. Updated almost 10 years ago.

Should have
Target version:
Start date:
Due date:
% Done:


Estimated time:
PHP Version:
Has patch:


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:

      phpBinaryPathAndFilename: 'C:\Program Files (x86)\Zend\ZendServer\bin\php.exe'

The correct escaped path should be:

"C:\Program Files (x86)\Zend\ZendServer\bin\php.exe" 

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.

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.


0001-fix-windows-shell-command-execution.patch (2.96 KB) 0001-fix-windows-shell-command-execution.patch fix windows shell command execution Alexander Berl, 2011-11-12 23:38

Related issues

Related to TYPO3.Flow - Bug #27995: Quote arguments in system command on WindowsResolvedBastian Waidelich2011-07-08

Is duplicate of TYPO3.Flow - Bug #30040: Missing quotes in system() command in initializeForRuntime()ResolvedBastian Waidelich2011-09-19


Updated by Bastian Waidelich about 10 years ago

  • Category changed from Command to Core
  • Status changed from New to Closed
  • Assignee 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.


Updated by Bastian Waidelich about 10 years ago

Could you please test if https://review.typo3.org/#change,6663 solves the issue for you?


Updated by Alexander Berl about 10 years ago

Yes, solves the problem for me. Thanks :)


Updated by Alexander Berl almost 10 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:

For the time being I just replaced escapeshellcmd with escapeshellarg and removed the manual quoting.

Also available in: Atom PDF