From 552fb9720ebba066b9b983a6415f7195e123216b Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Tue, 28 Nov 2017 23:46:09 +0100 Subject: =?UTF-8?q?Bugfix:=20The=20"excerpt"=20function=20had=20returned?= =?UTF-8?q?=20a=20string=20with=20unnecessary=20whitespace=20between=20the?= =?UTF-8?q?=20truncated=20text=20and=20the=20$replace=20string=20("[?= =?UTF-8?q?=E2=80=A6]")=20if=20the=20truncated=20text=20from=20the=20regul?= =?UTF-8?q?ar=20expression=20had=20contained=20whitespace=20at=20the=20end?= =?UTF-8?q?=20(before=20it=20was=20concatenated=20with=20$replace).=20This?= =?UTF-8?q?=20issue=20has=20been=20fixed=20by=20passing=20the=20truncated?= =?UTF-8?q?=20text=20directly=20after=20truncation=20to=20the=20"trim"=20f?= =?UTF-8?q?unction=20(before=20the=20truncated=20text=20is=20concatenated?= =?UTF-8?q?=20with=20$replace).=20In=20addition,=20the=20now=20unnecessary?= =?UTF-8?q?=20"trim"=20call=20within=20the=20"excerpt"=20function=20has=20?= =?UTF-8?q?been=20removed.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/functions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/functions.php b/core/functions.php index 6ef8894..1f7bfbb 100644 --- a/core/functions.php +++ b/core/functions.php @@ -232,7 +232,9 @@ function getRandomValue($length = 40): string { #=============================================================================== function cut($string, $length, $replace = ' […]') { if(mb_strlen($string) > $length) { - return preg_replace("/^(.{1,{$length}}\\b).*/su", "\\1{$replace}", $string); + return preg_replace_callback("/^(.{1,{$length}}\\b).*/su", function($match) { + return trim($match[1]); + }, $string).$replace; } return $string; @@ -245,7 +247,6 @@ function excerpt($string, $length = 500, $replace = ' […]') { $string = removeHTML($string); $string = removeDoubleLineBreaks($string); $string = cut($string, $length, $replace); - $string = trim($string); $string = nl2br($string); return $string; -- cgit v1.2.3