Bug #27995

Quote arguments in system command on Windows

Added by Bastian Waidelich about 4 years ago. Updated about 4 years ago.

Status:Resolved Start date:2011-07-08
Priority:Should have Due date:
Assigned To:Bastian Waidelich % Done:

100%

Category:Core
Target version:-
PHP Version: Complexity:
Has patch: Affected Flow version:

Description

The bootstrap currently does not quote system call arguments on Windows. This leads to errors if the path to your php binary contains spaces.

$command = 'SET FLOW3_ROOTPATH=' . FLOW3_PATH_ROOT . '&' . 'SET FLOW3_CONTEXT=' . $this->context . '&' . $this->settings['core']['phpBinaryPathAndFilename'] . ' -c ' . php_ini_loaded_file() . ' ' . FLOW3_PATH_FLOW3 . 'Scripts/flow3' . ' ' . escapeshellarg($commandIdentifier);

Should be changed to:

$command = 'SET FLOW3_ROOTPATH="' . FLOW3_PATH_ROOT . '"&' . 'SET FLOW3_CONTEXT="' . $this->context . '"&"' . $this->settings['core']['phpBinaryPathAndFilename'] . '" -c "' . php_ini_loaded_file() . '" "' . FLOW3_PATH_FLOW3 . 'Scripts/flow3' . ' ' . escapeshellarg($commandIdentifier) . '"';

TODO: Test


Related issues

related to TYPO3.Flow - Bug #31779: Command execution on Windows breaks with special chars in... Closed 2011-11-12

Associated revisions

Revision 7bb24f9d
Added by Bastian Waidelich about 4 years ago

[BUGFIX] Properly escape and quote CLI arguments

Currently arguments that are passed to the system() function in
Bootstrap::executeCommand() are not properly escaped.
This leads to errors if arguments / paths contain spaces.

Change-Id: Ief9eb0e1800cd9810867e607ba66456dcbb3ee4e
Resolves: #27995

History

#1 Updated by Adrian Föder about 4 years ago

we should also consider changing the REM in the new flow3.bat file from

REM This can include the php.ini to be used (for example "SET PHP=C:/php/php.exe -c C:/php/php.ini")

to some kind of

REM This can include the php.ini to be used (for example SET PHP="C:/php/php.exe" -c "C:/php/php.ini"    )

So we should directly write the double quotes even if they are not necessary in the example; but to avoid errors when user rely on that suggestion.

#2 Updated by Mr. Hudson about 4 years ago

  • Status changed from New to Under Review

Patch set 1 of change Ief9eb0e1800cd9810867e607ba66456dcbb3ee4e has been pushed to the review server.
It is available at http://review.typo3.org/3243

#3 Updated by Mr. Hudson about 4 years ago

Patch set 2 of change Ief9eb0e1800cd9810867e607ba66456dcbb3ee4e has been pushed to the review server.
It is available at http://review.typo3.org/3243

#4 Updated by Bastian Waidelich about 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF