Loading core/modules/views/src/Plugin/views/field/FieldPluginBase.php +3 −10 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ use Drupal\Component\Utility\Html; use Drupal\Component\Render\MarkupInterface; use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\Xss; use Drupal\Core\Form\FormStateInterface; Loading Loading @@ -1871,17 +1872,9 @@ public static function trimText($alter, $value) { if (mb_strlen($value) > $alter['max_length']) { $value = mb_substr($value, 0, $alter['max_length']); if (!empty($alter['word_boundary'])) { $regex = "(.*)\b.+"; if (function_exists('mb_ereg')) { mb_regex_encoding('UTF-8'); $found = mb_ereg($regex, $value, $matches); } else { $regex = '(.*)(?=[' . Unicode::PREG_CLASS_WORD_BOUNDARY . ']).+'; $found = preg_match("/$regex/us", $value, $matches); } if ($found) { $value = $matches[1]; } $value = $found ? $matches[1] : ''; } // Remove scraps of HTML entities from the end of a strings. $value = rtrim(preg_replace('/(?:<(?!.+>)|&(?!.+;)).*$/us', '', $value)); Loading core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php +3 −0 Original line number Diff line number Diff line Loading @@ -795,6 +795,7 @@ public function testTrimText(): void { 'của hãng bao gồm ba dòng', 'сд асд асд ас', 'асд асд асд ас', 'हिंदी परीक्षण स्ट्रिंग', ]; // Just test maxlength without word boundary. $alter = [ Loading @@ -809,6 +810,7 @@ public function testTrimText(): void { 'của hãng b', 'сд асд асд', 'асд асд ас', 'हिंदी परीक', ]; foreach ($text as $key => $line) { Loading @@ -827,6 +829,7 @@ public function testTrimText(): void { 'của hãng', 'сд асд', 'асд асд', 'हिंदी', ]; foreach ($text as $key => $line) { Loading Loading
core/modules/views/src/Plugin/views/field/FieldPluginBase.php +3 −10 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ use Drupal\Component\Utility\Html; use Drupal\Component\Render\MarkupInterface; use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\Xss; use Drupal\Core\Form\FormStateInterface; Loading Loading @@ -1871,17 +1872,9 @@ public static function trimText($alter, $value) { if (mb_strlen($value) > $alter['max_length']) { $value = mb_substr($value, 0, $alter['max_length']); if (!empty($alter['word_boundary'])) { $regex = "(.*)\b.+"; if (function_exists('mb_ereg')) { mb_regex_encoding('UTF-8'); $found = mb_ereg($regex, $value, $matches); } else { $regex = '(.*)(?=[' . Unicode::PREG_CLASS_WORD_BOUNDARY . ']).+'; $found = preg_match("/$regex/us", $value, $matches); } if ($found) { $value = $matches[1]; } $value = $found ? $matches[1] : ''; } // Remove scraps of HTML entities from the end of a strings. $value = rtrim(preg_replace('/(?:<(?!.+>)|&(?!.+;)).*$/us', '', $value)); Loading
core/modules/views/tests/src/Kernel/Handler/FieldKernelTest.php +3 −0 Original line number Diff line number Diff line Loading @@ -795,6 +795,7 @@ public function testTrimText(): void { 'của hãng bao gồm ba dòng', 'сд асд асд ас', 'асд асд асд ас', 'हिंदी परीक्षण स्ट्रिंग', ]; // Just test maxlength without word boundary. $alter = [ Loading @@ -809,6 +810,7 @@ public function testTrimText(): void { 'của hãng b', 'сд асд асд', 'асд асд ас', 'हिंदी परीक', ]; foreach ($text as $key => $line) { Loading @@ -827,6 +829,7 @@ public function testTrimText(): void { 'của hãng', 'сд асд', 'асд асд', 'हिंदी', ]; foreach ($text as $key => $line) { Loading