Fixed bug #12230: Function tslib_cObj::crop() is not fully multibyte safe (Thanks...
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / class.tslib_content.php
index 4fbbd59..68535ab 100644 (file)
@@ -834,6 +834,7 @@ class tslib_cObj {
                        'SEARCHRESULT' => 'SearchResult',
                        'PHP_SCRIPT' => 'PhpScript',
                        'PHP_SCRIPT_INT' => 'PhpScriptInternal',
+                       'PHP_SCRIPT_EXT' => 'PhpScriptExternal',
                        'TEMPLATE' => 'Template',
                        'FLUIDTEMPLATE' => 'FluidTemplate',
                        'MULTIMEDIA' => 'Multimedia',
@@ -2034,7 +2035,7 @@ class tslib_cObj {
                                        }
 
                                        // hand over the whole $conf array to the stdWrapHookObjects
-                                       if ($conf[$functionName] == 'stdWrapHookObject') {
+                                       if ($functionType === 'hook') {
                                                $singleConf = $conf;
                                        }
                                        // check if key is still containing something, since it might have been changed by next level stdWrap before
@@ -3593,15 +3594,20 @@ class tslib_cObj {
                $afterstring = trim($options[1]);
                $crop2space = trim($options[2]);
                if ($chars) {
-                       if (strlen($content) > abs($chars)) {
+                       if ($GLOBALS['TSFE']->csConvObj->strlen($GLOBALS['TSFE']->renderCharset, $content) > abs($chars)) {
+                               $truncatePosition = FALSE;
                                if ($chars < 0) {
                                        $content = $GLOBALS['TSFE']->csConvObj->substr($GLOBALS['TSFE']->renderCharset, $content, $chars);
-                                       $trunc_at = strpos($content, ' ');
-                                       $content = ($trunc_at && $crop2space) ? $afterstring . substr($content, $trunc_at) : $afterstring . $content;
+                                       if ($crop2space) {
+                                               $truncatePosition = strpos($content, ' ');
+                                       }
+                                       $content = ($truncatePosition) ? $afterstring . substr($content, $truncatePosition) : $afterstring . $content;
                                } else {
                                        $content = $GLOBALS['TSFE']->csConvObj->substr($GLOBALS['TSFE']->renderCharset, $content, 0, $chars);
-                                       $trunc_at = strrpos($content, ' ');
-                                       $content = ($trunc_at && $crop2space) ? substr($content, 0, $trunc_at) . $afterstring : $content . $afterstring;
+                                       if ($crop2space) {
+                                               $truncatePosition = strrpos($content, ' ');
+                                       }
+                                       $content = ($truncatePosition) ? substr($content, 0, $truncatePosition) . $afterstring : $content . $afterstring;
                                }
                        }
                }