[TYPO3-core] RFC #12297: t3lib_cs::cropMbstring has problems with negative length

Steffen Gebert steffen at steffen-gebert.de
Sat Nov 21 15:59:18 CET 2009


Am 21.10.2009, 10:27 Uhr, schrieb Steffen Gebert  
<steffen at steffen-gebert.de>:

> Hi,
>
> This is an SVN patch request.
>
> Type: Bugfix
>
> Bugtracker references:
> http://bugs.typo3.org/view.php?id=12297
>
> Branches: trunk
>
> Problem:
> function cropMbstring($charset, $string, $len, $crop = '')
> as always, $len can also be negative and is correctly handled.
> But the check, weather the string should really be truncated is as
> followed:
> if (intval($len) == 0 || mb_strlen($string) < $len) {
>      return $string;
> }
> So, if $len < 0, we never return here, but later prepend "...".
>
> Solution:
> check length <= abs($len)
>
> Note:
> I also changed the comparison from < to <= (we don't have to crop, if our
> string has exactly the maximum length ;)).
> An example for this is the page path on the top right: It will also
> prepend the shortest title with "..."
> Make sure, you have mbstring enabled.
>
REMINDER

This one is really easy and obvious ;-)

Steffen


More information about the TYPO3-team-core mailing list