From 95b8b50599bd8df01cc3f97f72d6b2ae6eac61e1 Mon Sep 17 00:00:00 2001 From: Ruben Calvo Date: Tue, 9 Jul 2024 17:09:06 +0200 Subject: [PATCH] [ticket/15403] Return first fragment of text if there is no coincidences PHPBB-15403 --- phpBB/includes/functions_content.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index a207fc28e9..25144f5af3 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -398,10 +398,10 @@ function get_context(string $text, array $words, int $length = 400) // Get the last fragment $fragments[] = $fragment; - $output = htmlentities(implode('', $fragments)); + return htmlentities(implode('', $fragments)); } - return $output; + return htmlentities($text_length >= $length + 3 ? utf8_substr($text, 0, $length) . ' ...' : $text); } /**