Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorStefan Giehl <stefan@piwik.org>2017-12-13 23:49:21 +0300
committerMatthieu Aubry <mattab@users.noreply.github.com>2017-12-13 23:49:21 +0300
commit56f7bc5a879e868436c4286cb4cfb6983d12bf54 (patch)
tree6ea24ff036561415ee66c6f1985afc02503a9bf3 /core
parentf91f646c2f5df8d4432aa86db2a2f4a3d9a50452 (diff)
Improves truncate twig filter (#12347)
* respect encoded entities in truncate filter * adds some simple tests
Diffstat (limited to 'core')
-rwxr-xr-xcore/Twig.php6
1 files changed, 3 insertions, 3 deletions
diff --git a/core/Twig.php b/core/Twig.php
index c36452055b..24fd09eec2 100755
--- a/core/Twig.php
+++ b/core/Twig.php
@@ -25,11 +25,11 @@ use Twig_SimpleTest;
function piwik_filter_truncate($string, $size)
{
- if (strlen($string) < $size) {
+ if (Common::mb_strlen(html_entity_decode($string)) <= $size) {
return $string;
} else {
- $array = str_split($string, $size);
- return array_shift($array) . "...";
+ preg_match('/^(&(?:[a-z\d]+|#\d+|#x[a-f\d]+);|.){'.$size.'}/i', $string, $shortenString);
+ return reset($shortenString) . "...";
}
}