Fixed bug #12230: Function tslib_cObj::crop() is not fully multibyte safe (Thanks...
authorChristian Kuhn <lolli@schwarzbu.ch>
Thu, 10 Feb 2011 19:42:56 +0000 (19:42 +0000)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 10 Feb 2011 19:42:56 +0000 (19:42 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/branches/TYPO3_4-5@10432 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/cms/tslib/class.tslib_content.php

index 574783d..f265dcf 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-02-10  Christian Kuhn  <lolli@schwarzbu.ch>
+
+       * Fixed bug #12230: Function tslib_cObj::crop() is not fully multibyte safe (Thanks to Vladimir Podkovanov)
+
 2011-02-09  Steffen Kamper  <steffen@typo3.org>
 
        * Fixed bug #17501: User setup - pressing return creates installtool file
index 5a6de62..68535ab 100644 (file)
@@ -3594,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;
                                }
                        }
                }