diff options
author | Andreas Fischer <bantu@phpbb.com> | 2010-08-10 16:00:28 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2010-08-10 16:00:28 +0200 |
commit | 19d9d1233976b65e7ed9be4315ded2b3d1d27674 (patch) | |
tree | accd33af9423a45be0006cf8ac304a0642ece117 | |
parent | 1778b53f1281306a7c35c56fb72335e2a070f925 (diff) | |
parent | 4d0a53b5ee88b9a5a810eb3bcb5cee35659ee5aa (diff) | |
download | forums-19d9d1233976b65e7ed9be4315ded2b3d1d27674.tar forums-19d9d1233976b65e7ed9be4315ded2b3d1d27674.tar.gz forums-19d9d1233976b65e7ed9be4315ded2b3d1d27674.tar.bz2 forums-19d9d1233976b65e7ed9be4315ded2b3d1d27674.tar.xz forums-19d9d1233976b65e7ed9be4315ded2b3d1d27674.zip |
Merge branch 'ticket/rxu/6747' into develop-olympus
* ticket/rxu/6747:
[ticket/9747] Improve word censor.
-rw-r--r-- | phpBB/includes/cache.php | 9 |
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 { |