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.

Status:
Closed
Priority:
Should have
Category:
Core
Target version:
-
Start date:
2011-11-12
Due date:
% Done:

0%

Estimated time:
PHP Version:
5.3
Has patch:
Yes
Complexity:

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.


Files

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

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

Actions

Also available in: Atom PDF