aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions.php
diff options
context:
space:
mode:
authorrxu <rxu@mail.ru>2011-01-08 12:11:02 +0700
committerAndreas Fischer <bantu@phpbb.com>2011-01-16 19:55:10 +0100
commit8c1866bc0c1ac4a3b58edfaf3f3914361deb1fab (patch)
tree2e10b243b1569d5b43d69a7df803688d9617a04d /phpBB/includes/functions.php
parent1359cf654714107f752d14a358d76ee310a9ff57 (diff)
downloadforums-8c1866bc0c1ac4a3b58edfaf3f3914361deb1fab.tar
forums-8c1866bc0c1ac4a3b58edfaf3f3914361deb1fab.tar.gz
forums-8c1866bc0c1ac4a3b58edfaf3f3914361deb1fab.tar.bz2
forums-8c1866bc0c1ac4a3b58edfaf3f3914361deb1fab.tar.xz
forums-8c1866bc0c1ac4a3b58edfaf3f3914361deb1fab.zip
[ticket/9933] Adjust word censor regex for non-unicode mode.
PHPBB3-9933
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r--phpBB/includes/functions.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 69be1627cf..20d9d4e0f5 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -3451,11 +3451,11 @@ function get_censor_preg_expression($word)
$unicode = ((version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) && @preg_match('/\p{L}/u', 'a') !== false) ? true : false;
}
+ // Unescape the asterisk to simplify further conversions
+ $word = str_replace('\*', '*', preg_quote($word, '#'));
+
if ($unicode)
{
- // Unescape the asterisk to simplify further conversions
- $word = str_replace('\*', '*', preg_quote($word, '#'));
-
// Replace asterisk(s) inside the pattern, at the start and at the end of it with regexes
$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}_-]*?'), $word);
@@ -3464,7 +3464,11 @@ function get_censor_preg_expression($word)
}
else
{
- $preg_expr = '#(?<!\S)(' . str_replace('\*', '\S*?', preg_quote($word, '#')) . ')(?!\S)#iu';
+ // Replace the asterisk inside the pattern, at the start and at the end of it with regexes
+ $word = preg_replace(array('#(?<=\S)\*+(?=\S)#iu', '#^\*+#', '#\*+$#'), array('(\x20*?\S*?)', '\S*?', '\S*?'), $word);
+
+ // Generate the final substitution
+ $preg_expr = '#(?<!\S)(' . $word . ')(?!\S)#iu';
}
return $preg_expr;