aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_content.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2009-07-24 08:56:06 +0000
committerJoas Schilling <nickvergessen@gmx.de>2009-07-24 08:56:06 +0000
commit433f03107de1162744a1d0b8c9fa3c4ba1b3ed21 (patch)
tree62dc8d7fe3f85cb255ae83c0a2f873f78b5a5e1b /phpBB/includes/functions_content.php
parentf84cbee47c06dd9df3b2cf7085a3b37ab9095d09 (diff)
downloadforums-433f03107de1162744a1d0b8c9fa3c4ba1b3ed21.tar
forums-433f03107de1162744a1d0b8c9fa3c4ba1b3ed21.tar.gz
forums-433f03107de1162744a1d0b8c9fa3c4ba1b3ed21.tar.bz2
forums-433f03107de1162744a1d0b8c9fa3c4ba1b3ed21.tar.xz
forums-433f03107de1162744a1d0b8c9fa3c4ba1b3ed21.zip
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
Diffstat (limited to 'phpBB/includes/functions_content.php')
-rw-r--r--phpBB/includes/functions_content.php9
1 files changed, 7 insertions, 2 deletions
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('&lt;', '&gt;', '&#91;', '&#93;', '&#46;', '&#58;', '&#058;');
+ $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));
}
}