aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/cache.php
diff options
context:
space:
mode:
authorrxu <rxu@mail.ru>2010-07-25 16:57:00 +0800
committerrxu <rxu@mail.ru>2010-07-25 16:57:00 +0800
commit4d0a53b5ee88b9a5a810eb3bcb5cee35659ee5aa (patch)
treebbab149d905e00a2110834f473394dbc01213cad /phpBB/includes/cache.php
parentfc25fe694afdab683789c9ed962c77558f85796c (diff)
downloadforums-4d0a53b5ee88b9a5a810eb3bcb5cee35659ee5aa.tar
forums-4d0a53b5ee88b9a5a810eb3bcb5cee35659ee5aa.tar.gz
forums-4d0a53b5ee88b9a5a810eb3bcb5cee35659ee5aa.tar.bz2
forums-4d0a53b5ee88b9a5a810eb3bcb5cee35659ee5aa.tar.xz
forums-4d0a53b5ee88b9a5a810eb3bcb5cee35659ee5aa.zip
[ticket/9747] Improve word censor.
Better handling of the asterisk inside censor pattern like 'bad*word' etc. PHPBB3-9747
Diffstat (limited to 'phpBB/includes/cache.php')
-rw-r--r--phpBB/includes/cache.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/phpBB/includes/cache.php b/phpBB/includes/cache.php
index 6b1e078ca4..b50fab4ca2 100644
--- a/phpBB/includes/cache.php
+++ b/phpBB/includes/cache.php
@@ -88,7 +88,14 @@ class cache extends acm
{
if ($unicode)
{
- $censors['match'][] = '#(?<![\p{Nd}\p{L}_])(' . str_replace('\*', '[\p{Nd}\p{L}_]*?', preg_quote($row['word'], '#')) . ')(?![\p{Nd}\p{L}_])#iu';
+ // Unescape the asterisk to simplify further conversions
+ $row['word'] = str_replace('\*', '*', preg_quote($row['word'], '#'));
+
+ // Replace the asterisk inside the pattern, at the start and at the end of it with regexes
+ $row['word'] = preg_replace(array('#(?<=[\p{Nd}\p{L}_])\*(?=[\p{Nd}\p{L}_])#iu', '#^\*#', '#\*$#'), array('([\x20]*?|[\p{Nd}\p{L}_-]*?)', '[\p{Nd}\p{L}_-]*?', '[\p{Nd}\p{L}_-]*?'), $row['word']);
+
+ // Generate the final substitution
+ $censors['match'][] = '#(?<![\p{Nd}\p{L}_-])(' . $row['word'] . ')(?![\p{Nd}\p{L}_-])#iu';
}
else
{