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

Steffen Gebert steffen at steffen-gebert.de
Sun Nov 1 11:31:04 CET 2009


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

> 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


More information about the TYPO3-team-core mailing list