1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 05:50:42 +02:00

Fix bug #31505 - Do not cut post-message in between HTML-Entities on search.php - Patch by leviatan21

Authorised by: AcydBurn


git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9842 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Joas Schilling
2009-07-24 08:56:06 +00:00
parent f84cbee47c
commit 433f03107d
2 changed files with 8 additions and 2 deletions

View File

@@ -250,6 +250,11 @@ function get_context($text, $words, $length = 400)
// first replace all whitespaces with single spaces
$text = preg_replace('/ +/', ' ', strtr($text, "\t\n\r\x0C ", ' '));
// we need to turn the entities back into their original form, to not cut the message in between them
$entities = array('<', '>', '[', ']', '.', ':', ':');
$characters = array('<', '>', '[', ']', '.', ':', ':');
$text = str_replace($entities, $characters, $text);
$word_indizes = array();
if (sizeof($words))
{
@@ -345,13 +350,13 @@ function get_context($text, $words, $length = 400)
}
}
}
return $final_text;
return str_replace($characters, $entities, $final_text);
}
}
if (!sizeof($words) || !sizeof($word_indizes))
{
return (utf8_strlen($text) >= $length + 3) ? utf8_substr($text, 0, $length) . '...' : $text;
return str_replace($characters, $entities, ((utf8_strlen($text) >= $length + 3) ? utf8_substr($text, 0, $length) . '...' : $text));
}
}