[wp-trac] [WordPress Trac] #19551: Please provide option to match whole words for comment moderation
WordPress Trac
wp-trac at lists.automattic.com
Wed Dec 14 20:54:32 UTC 2011
#19551: Please provide option to match whole words for comment moderation
-----------------------------+-----------------------------
Reporter: jwz | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Comments | Version: 3.3
Severity: normal | Keywords:
-----------------------------+-----------------------------
The "Comment Moderation" and "Comment Blacklist" fields are documented to
match inside words. However, I find that less useful than the alternative,
of matching whole words.
With each WP release, I have to modify the source to add \b to the regexp.
It would be better if there was a preference option to say whether you
want to match whole words or not. Alternately, there could be an option
to just let me type real regexps into the field directly.
{{{
--- wp-includes/comment.php 14 Dec 2011 19:42:49 -0000 1.5
+++ wp-includes/comment.php 14 Dec 2011 19:43:31 -0000
@@ -69,9 +69,7 @@
// spam words don't break things:
$word = preg_quote($word, '#');
- // jwz: match whole words only.
- $pattern = "#\\b$word\\b#i";
-
+ $pattern = "#$word#i";
if ( preg_match($pattern, $author) ) return false;
if ( preg_match($pattern, $email) ) return false;
if ( preg_match($pattern, $url) ) return false;
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19551>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list