Bug #24931
closedQuoting of path and filename in ImageMagick/GraphicsMagick not working on Windows + PHP5.2
0%
Description
Quoting of the path and filename of the ImageMagick/GraphicsMagick executable has been introduced with 4.4.5. Here is an example:
4.4.4: C:\Programme\GraphicsMagick-1.3.7-Q8/gm.exe convert -geometry 50x50! "uploads/pics/myimage.gif[0]" "typo3temp/pics/f58c0b5193.gif"
4.4.5: "C:/Programme/GraphicsMagick-1.3.7-Q8/gm.exe" convert +profile '*' -geometry 50x50! "uploads/pics/myimage.gif"[0] "typo3temp/pics/f58c0b5193.gif"
Both of these commands will work, if executed directly on the Windows command line. But the 4.4.5 version will fail when executed through the PHP exec() command on Windows <b>with PHP versions below 5.3</b>.
For the exec() command of PHP >=5.3 both commands will work nicely.
<b>Explanation for PHP < 5.3:</b>
The quoting of the IM/GM executable path and filename in the complete command line requires the whole string to be quoted a second time, to make it work with exec() on Windows. Details can be found in the posting of "luko post cz", 30-Jan-2008 02:15, on http://php.net/manual/en/ref.exec.php
The working version for 4.4.5 must look like this:
""C:/Programme/GraphicsMagick-1.3.7-Q8/gm.exe" convert +profile '*' -geometry 50x50! "uploads/pics/myimage.gif"[0] "typo3temp/pics/f58c0b5193.gif""
<b>Explanation for PHP >=5.3:</b>
The PHP 5.3.0 change log (http://php.net/ChangeLog-5.php) contains a hint that the exec() behavior has been changed:
Version 5.3.0 30-June-2009 ... Fixed exec() on Windows to not eat the first and last double quotes. (Scott)
<b>Bottom line</b>
Quoting twice is the way to go on Windows, but is needed and working only for PHP versions below 5.3 on Windows. For PHP >=5.3 this is NOT needed and actually results in an error!
The attached patches for TYPO3 4.4.5 and TYPO3 4.5.0 will correct the problem with all PHP 5 versions on Windows.
(issue imported from #M17447)
Files
Updated by Jörg Wagner almost 14 years ago
This report should be marked as child of #0013750.
Updated by Jigal van Hemert almost 14 years ago
Solution in 16656 also works. Both solutions have the same problem: they won't work with safe_mode enabled.
Maybe the best possible solution is to only use quotes if it is really necessary and to only use a dummy command (or extra quotes) if the command begins and ends with a quote && PHP <5.3 && OS==win
This won't work in all circumstances, but it increases the number of installations where it will work. Maybe we should log a warning in cases which are known not to work
Updated by Markus Kappe over 13 years ago
Additional info: http://de.php.net/manual/en/function.exec.php#198369
The patch should be placed in t3lib_utility_Command::exec()
Updated by Jigal van Hemert over 13 years ago
solved in #24281, so this one can be closed as duplicate