Bug #31779 ยป 0001-fix-windows-shell-command-execution.patch

fix windows shell command execution - Alexander Berl, 2011-11-12 23:38

View differences:

Classes/Core/Bootstrap.php
413 413
		}
414 414

  
415 415
		if ($objectConfigurationCache->has('allCompiledCodeUpToDate') === FALSE) {
416
			$command = escapeshellcmd($this->settings['core']['phpBinaryPathAndFilename']) . ' -c ' . escapeshellarg(php_ini_loaded_file()) . ' -v';
416
			$command = $this->escapeShellCmd($this->settings['core']['phpBinaryPathAndFilename']) . ' -c ' . escapeshellarg(php_ini_loaded_file()) . ' -v';
417 417
			system($command, $result);
418 418
			if ($result !== 0) {
419 419
				throw new \TYPO3\FLOW3\Exception('It seems like the PHP binary "' . $this->settings['core']['phpBinaryPathAndFilename'] . '" cannot be executed by FLOW3. Set the correct path to the PHP executable in Configuration/Settings.yaml, setting FLOW3.core.phpBinaryPathAndFilename.', 1315561483);
......
471 471
		if (DIRECTORY_SEPARATOR === '/') {
472 472
			$command = 'XDEBUG_CONFIG="idekey=FLOW3_SUBREQUEST" FLOW3_ROOTPATH=' . \escapeshellarg(FLOW3_PATH_ROOT) . ' ' . 'FLOW3_CONTEXT=' . \escapeshellarg($this->context) . ' ' . \escapeshellcmd($this->settings['core']['phpBinaryPathAndFilename']) . ' -c ' . \escapeshellarg(php_ini_loaded_file()) . ' ' . \escapeshellarg(FLOW3_PATH_FLOW3 . 'Scripts/flow3.php') . ' ' . escapeshellarg($commandIdentifier);
473 473
		} else {
474
			$command = 'SET FLOW3_ROOTPATH=' . \escapeshellarg(FLOW3_PATH_ROOT) . '&' . 'SET FLOW3_CONTEXT=' . \escapeshellarg($this->context) . '&' . \escapeshellcmd($this->settings['core']['phpBinaryPathAndFilename']) . ' -c ' . \escapeshellarg(php_ini_loaded_file()) . ' ' . \escapeshellarg(FLOW3_PATH_FLOW3 . 'Scripts/flow3.php') . ' ' . \escapeshellarg($commandIdentifier);
474
			$command = 'SET FLOW3_ROOTPATH=' . \escapeshellarg(FLOW3_PATH_ROOT) . '&' . 'SET FLOW3_CONTEXT=' . \escapeshellarg($this->context) . '&' . $this->escapeShellCmd($this->settings['core']['phpBinaryPathAndFilename']) . ' -c ' . \escapeshellarg(php_ini_loaded_file()) . ' ' . \escapeshellarg(FLOW3_PATH_FLOW3 . 'Scripts/flow3.php') . ' ' . \escapeshellarg($commandIdentifier);
475 475
		}
476 476
		system($command, $result);
477 477
		return $result === 0;
......
890 890
	}
891 891

  
892 892
	/**
893
	 * Escape a shell command and quote it on Win
894
	 * 
895
	 * @param string $command The shell command to escape
896
	 * @return string
897
	 */
898
	protected function escapeShellCmd($command) {
899
	    if (DIRECTORY_SEPARATOR === '/') {
900
	        return escapeshellcmd($command);
901
	    } else {
902
	        return escapeshellarg($command);
903
	    }
904
	}
905
	
906
	/**
893 907
	 * Checks PHP version and other parameters of the environment
894 908
	 *
895 909
	 * @return void
896
- 
    (1-1/1)