[TYPO3-core] RFC #16656 : bug : ImageMagick does not work with quotes in exec() path on Windows

Žiga Dolhar ziga at dolhar.si
Tue Dec 28 22:37:23 CET 2010


Hey Jigal,

I installed 4.5beta3 and noticed there were some changes in respect to 
mitigating this issue, which prohibit application of your patch. In 
particular (as noted in another discussion on the list), 
class.t3lib_utility_command.php was created and some functionality moved 
there.

I - being well aware that I don't have any knowledge of typo3 core 
beyond what I was able to learn studying your patch - decided to, at 
least temporarily, try "applying" your patch the following way.

At the end of t3lib_utility_command file, I replaced the

	return $cmdLine;

***

with the following:

***

		$prefixCommand = self::prefixCommandLine($path);
		return $prefixCommand . $cmdLine;
	}
	
  	/**
	 * Builds prefix for command line calls in Windows
	 *
	 * When using a call to a command line function in Windows and PHP < 
5.3.0 and if there are more than two double quotes in
	 * the command will simply not work due to a bug in PHP. A workaround 
is to add a dummy command in front of the actual
	 * command
	 *
	 * @static
	 * @param string $path Path to command
	 * @return string Prefix for command
	 */
	protected static function prefixCommandLine($path) {
		$prefixCommand = '';
		if (TYPO3_OS == 'WIN' && version_compare(phpversion(), '5.3.0') == -1) {
			if (preg_match('/([a-z]:)/i', $path, $matches)) {
					// if a drive letter is found, use it
				$prefixCommand = $matches[1] . ' & ';
			} else {
					// fallback is drive c:, which should be present in Windows 
installations
				$prefixCommand = 'c: & ';
			}
		}
		return $prefixCommand;
	}	
***

And the images work again. I realize this is probably not the way the 
final patch will be applied, but it at least works until the official 
patch is ordained :-).

Yours, Žiga


On 14.12.2010 8:23, Jigal van Hemert wrote:
> Hi,
>
> This is a SVN patch request.
>
> Type: Bugfix
>
> BT reference: http://bugs.typo3.org/view.php?id=16656
>
> Branches: trunk / 4.4
>
> Problem:
> If the following conditions are met
> - OS is Windows
> - PHP version is below 5.3
> - more than two double quotes are present in the command
> a call to a command line function such as exec() will fail due to a bug
> in the way PHP calls the command line processor. PHP 5.2 will not
> receive any updates anymore, so this bug will not be solved in PHP.
>
> Solution:
> Three workarounds are possible:
> - use "short path" names (aka DOS 8.3 names), but these are not active
> in all Windows installations
> - put the command in a .bat file and execute that file
> - put a dummy command in front of the actual command (e.g. c: & ----- )
>
> The least intrusive solution is the last one, because we won't have to
> take care about cleaning up the .bat files.
>
> Notes:
> I will look into a solution for the Install Tool too.
>



More information about the TYPO3-team-core mailing list