diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index f235be1e9b..afba5d32f3 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -173,6 +173,7 @@
[Fix] Fix set_custom_template for database-stored styles (Bug #40515 - Patch by nickvergessen)
[Fix] Banning an already banned user states to be successful, but has no effect (Bug #47825 - Patch by Pyramide)
[Fix] Do not add style-parameter to URL again, after admin re-authentification (Bug #18005 - Patch by leviatan21)
+ [Fix] Do not cut post-message in between HTML-Entities on search.php (Bug #31505 - Patch by leviatan21)
[Change] Change the data format of the default file ACM to be more secure from tampering and have better performance.
[Change] Add index on log_time to the log table to prevent slowdown on boards with many log entries. (Bug #44665 - Patch by bantu)
[Change] Template engine now permits to a limited extent variable includes.
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index 630f4105d0..de5df37299 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -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));
}
}