Fixed bug #6001: Install Tool image tests fail when there are spaces in the path...
authorErnesto Baschny <ernst@cron-it.de>
Fri, 12 Nov 2010 21:45:56 +0000 (21:45 +0000)
committerErnesto Baschny <ernst@cron-it.de>
Fri, 12 Nov 2010 21:45:56 +0000 (21:45 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9354 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_div.php
typo3/sysext/install/mod/class.tx_install.php

index c131fe4..7700eea 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@
 
        * Fixed bug #16370, Follow-up to #15094: SVG TypoScript object unuseable after tslib_content splitup
        * Fixed bug #15456: Changes made by ColorPicker Wizard are not saved (Thanks to Tobias Hoevelborn)
+       * Fixed bug #6001: Install Tool image tests fail when there are spaces in the path name of im_path, and auto-detection of IM under Windows improved
 
 2010-11-12  Stanislas Rolland  <typo3@sjbr.ca>
 
index dc23190..87c2a3d 100644 (file)
@@ -5947,7 +5947,7 @@ final class t3lib_div {
         *
         * @param       string          Command to be run: identify, convert or combine/composite
         * @param       string          The parameters string
-        * @param       string          Override the default path
+        * @param       string          Override the default path (e.g. used by the install tool)
         * @return      string          Compiled command that deals with IM6 & GraphicsMagick
         */
        public static function imageMagickCommand($command, $parameters, $path='')      {
@@ -5956,6 +5956,7 @@ final class t3lib_div {
                $switchCompositeParameters=false;
 
                if(!$path)      { $path = $gfxConf['im_path']; }
+               $path = self::fixWindowsFilePath($path);
 
                $im_version = strtolower($gfxConf['im_version_5']);
                $combineScript = $gfxConf['im_combine_filename'] ? trim($gfxConf['im_combine_filename']) : 'combine';
@@ -5967,10 +5968,10 @@ final class t3lib_div {
                        // Compile the path & command
                if($im_version==='gm')  {
                        $switchCompositeParameters=true;
-                       $path .= 'gm'.$isExt.' '.$command;
+                       $path = escapeshellarg($path . 'gm' . $isExt) . ' ' . $command;
                } else  {
                        if($im_version==='im6') { $switchCompositeParameters=true; }
-                       $path .= (($command=='composite') ? $combineScript : $command).$isExt;
+                       $path = escapeshellarg($path . (($command == 'composite') ? $combineScript : $command) . $isExt);
                }
 
                        // strip profile information for thumbnails and reduce their size
index caf7a70..f6c5841 100755 (executable)
@@ -1274,9 +1274,17 @@ REMOTE_ADDR was '".t3lib_div::getIndpEnv('REMOTE_ADDR')."' (".t3lib_div::getIndp
 
                if (TYPO3_OS=='WIN') {
                        $paths=array($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'], $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'], 'c:\\php\\imagemagick\\', 'c:\\php\\GraphicsMagick\\', 'c:\\apache\\ImageMagick\\', 'c:\\apache\\GraphicsMagick\\');
+                       if (!isset($_SERVER['PATH'])) {
+                               $serverPath = array_change_key_case($_SERVER, CASE_UPPER);
+                               $paths = array_merge($paths, explode(';', $serverPath['PATH']));
+                       } else {
+                               $paths = array_merge($paths, explode(';', $_SERVER['PATH']));
+                       }
                } else {
                        $paths=array($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'], $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'], '/usr/local/bin/','/usr/bin/','/usr/X11R6/bin/');
+                       $paths = array_merge($paths, explode(':', $_SERVER['PATH']));
                }
+               $paths = array_unique($paths);
 
                asort($paths);
                if (t3lib_utility_PhpOptions::isSafeModeEnabled()) {
@@ -3801,43 +3809,30 @@ REMOTE_ADDR was '".t3lib_div::getIndpEnv('REMOTE_ADDR')."' (".t3lib_div::getIndp
                                                        break;
                                                        case 'im_path':
                                                                list($value,$version) = explode('|',$value);
-                                                               if (!preg_match('/[[:space:]]/',$value,$reg) && strlen($value)<100) {
-                                                                       if (strcmp($GLOBALS['TYPO3_CONF_VARS']['GFX'][$key], $value)) {
-                                                                               $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\'][\'' . $key . '\']', $value);
-                                                                       }
-                                                                       if(doubleval($version)>0 && doubleval($version)<4) {    // Assume GraphicsMagick
-                                                                               $value_ext = 'gm';
-                                                                       } elseif(doubleval($version)<5) {       // Assume ImageMagick 4.x
-                                                                               $value_ext = '';
-                                                                       } elseif(doubleval($version) >= 6) {    // Assume ImageMagick 6.x
-                                                                               $value_ext = 'im6';
-                                                                       } else  {       // Assume ImageMagick 5.x
-                                                                               $value_ext = 'im5';
-                                                                       }
-                                                                       if (strcmp(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']),$value_ext)) {
-                                                                               $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\'][\'im_version_5\']', $value_ext);
-                                                                       }
-       //                                                              if (strcmp(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']),$value))      $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS['GFX']['im_version_5']', $value);
-                                                               } else {
-                                                                       $this->errorMessages[] = '
-                                                                               Path \'' . $value . '\' contains spaces
-                                                                               or is longer than 100 chars (...not
-                                                                               saved)
-                                                                       ';
+                                                               if (strcmp($GLOBALS['TYPO3_CONF_VARS']['GFX'][$key], $value)) {
+                                                                       $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\'][\'' . $key . '\']', $value);
+                                                               }
+                                                               if (doubleval($version) > 0 && doubleval($version) < 4) {
+                                                                               // Assume GraphicsMagick
+                                                                       $value_ext = 'gm';
+                                                               } elseif (doubleval($version) < 5) {
+                                                                               // Assume ImageMagick 4.x
+                                                                       $value_ext = '';
+                                                               } elseif (doubleval($version) >= 6) {
+                                                                               // Assume ImageMagick 6.x
+                                                                       $value_ext = 'im6';
+                                                               } else  {
+                                                                               // Assume ImageMagick 5.x
+                                                                       $value_ext = 'im5';
+                                                               }
+                                                               if (strcmp(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']), $value_ext)) {
+                                                                       $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\'][\'im_version_5\']', $value_ext);
                                                                }
                                                        break;
                                                        case 'im_path_lzw':
                                                                list($value) = explode('|',$value);
-                                                               if (!preg_match('/[[:space:]]/',$value) && strlen($value)<100) {
-                                                                       if (strcmp($GLOBALS['TYPO3_CONF_VARS']['GFX'][$key], $value)) {
-                                                                               $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\'][\'' . $key . '\']', $value);
-                                                                       }
-                                                               } else {
-                                                                       $this->errorMessages[] = '
-                                                                               Path \'' . $value . '\' contains spaces
-                                                                               or is longer than 100 chars (...not
-                                                                               saved)
-                                                                       ';
+                                                               if (strcmp($GLOBALS['TYPO3_CONF_VARS']['GFX'][$key], $value)) {
+                                                                       $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\'][\'' . $key . '\']', $value);
                                                                }
                                                        break;
                                                        case 'TTFdpi':