mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 13:28:55 +00:00
[ticket/15043] Update regexp
PHPBB3-15043
This commit is contained in:
parent
7365764476
commit
350c9213ee
1 changed files with 7 additions and 5 deletions
|
@ -331,7 +331,7 @@ function get_context($text, $words, $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);
|
||||
|
@ -362,9 +362,11 @@ function get_context($text, $words, $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