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

Steffen Gebert steffen at steffen-gebert.de
Wed Oct 21 10:27:01 CEST 2009


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.

Steffen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 12297.diff
Type: text/x-diff
Size: 619 bytes
Desc: not available
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20091021/9efd4948/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: screenshot.png
Type: image/png
Size: 9467 bytes
Desc: not available
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20091021/9efd4948/attachment.png>


More information about the TYPO3-team-core mailing list