mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/15043] Update regexp
PHPBB3-15043
This commit is contained in:
parent
13f7a8f82f
commit
02321c412c
1 changed files with 7 additions and 5 deletions
|
@ -330,7 +330,7 @@ function get_context(string $text, array $words, int $length = 400)
|
|||
$text_length = utf8_strlen($text);
|
||||
|
||||
// Replace all spaces/invisible characters with single spaces
|
||||
$text = preg_replace("/[[:^print:] ]+/", ' ', $text);
|
||||
$text = preg_replace("/\s+/", ' ', $text);
|
||||
|
||||
// we need to turn the entities back into their original form, to not cut the message in between them
|
||||
$text = html_entity_decode($text);
|
||||
|
@ -361,9 +361,11 @@ function get_context(string $text, array $words, int $length = 400)
|
|||
$start = $end = 0;
|
||||
foreach ($word_indizes as $indize => $word)
|
||||
{
|
||||
// Check if the next word can be inside the current fragment of text
|
||||
if ($end + $characters_per_word + utf8_strlen($word) < $indize)
|
||||
{
|
||||
$fragment = utf8_substr($text, $start, $end-$start);
|
||||
|
||||
if ($start != 0)
|
||||
{
|
||||
$fragment = '... ' . $fragment;
|
||||
|
|
Loading…
Add table
Reference in a new issue