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

Susanne Moog typo3 at susannemoog.de
Mon Nov 9 09:05:21 CET 2009


Hi,

Steffen Gebert schrieb:
> 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.

+1 by reading.


Susanne


More information about the TYPO3-team-core mailing list