Skip to content
Snippets Groups Projects
Commit 2a210685 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Correction de Util::truncatedString boguée

parent a668402e
No related branches found
No related tags found
No related merge requests found
Pipeline #9122 failed
...@@ -338,11 +338,20 @@ class Util ...@@ -338,11 +338,20 @@ class Util
if (strlen($string) <= $length) { if (strlen($string) <= $length) {
return $string; return $string;
} }
$trunc = substr($string, 0, $length);
if ($string[$length] === ' ') { if ($string[$length] === ' ') {
return substr($string, 0, $length) . $appended; $kept = $trunc;
} else {
$found = strrpos($trunc, ' '); // position du dernier espace
if ($found === false) {
$kept = $trunc;
} else {
$kept = substr($string, 0, $found); // on tronque à l'espace trouvé
}
} }
return substr($string, 0, strrpos(substr($string, 0, $length), ' ')) . $appended; return $kept . $appended;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment