Fixes #11026: Fixed StringHelper::truncateWords() to count words properly for non-English text

This commit is contained in:
Alexander Makarov
2016-03-30 00:26:56 +03:00
parent 91bc1b518c
commit cfbe50e96d
3 changed files with 3 additions and 1 deletions

View File

@ -165,7 +165,7 @@ class BaseStringHelper
} elseif ($token instanceof \HTMLPurifier_Token_Text && $totalCount <= $count) { //Text
if (false === $encoding) {
$token->data = self::truncateWords($token->data, $count - $totalCount, '');
$currentCount = str_word_count($token->data);
$currentCount = self::countWords($token->data);
} else {
$token->data = self::truncate($token->data, $count - $totalCount, '', $encoding) . ' ';
$currentCount = mb_strlen($token->data, $encoding);