Commit 2a210685 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Correction de Util::truncatedString boguée

parent a668402e
Loading
Loading
Loading
Loading
Loading
+11 −2
Changes for src/UnicaenApp/Util.php: 11 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -338,11 +338,20 @@ class Util
        if (strlen($string) <= $length) {
            return $string;
        }

        $trunc = substr($string, 0, $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;
    }