mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/9747] Improve word censor.
Better handling of the asterisk inside censor pattern like 'bad*word' etc. PHPBB3-9747
This commit is contained in:
parent
fc25fe694a
commit
4d0a53b5ee
1 changed files with 8 additions and 1 deletions
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue