6/1/2004 ↓

Spam words bug

Thanks for visiting! If you're new here, you may want to subscribe to our RSS feed. This blog posts regular Wordpress news, updates of themes, plugins, ideas, hacks, quick fixes and everything about blogging, especially about Wordpress. Go ahead, subscribe to our feed! You can also receive updates from this blog via email.

In WP 1.2 there’s a bug in the built-in blacklist function. If you haven’t tried this out as a way of protecting your blog from comment spam, you should look into this.

The default list is empty, and you can enter words, author names, email addresses, IP address, and URI/URLs. If any word in the list matches anything in the comment text, comment author’s name, comment author’s email address, comment author’s URL, or comment author’s IP address, the comment will be held for moderation.

The bug is that if there’s a blank line in or at the end of the list, it’s treated as a wildcard, and it matches anything in the comment body. So all comments will be moderated regardless of comments.

This is fixed in the CVS, but I thought I’d publish the fix for those that don’t want to run a diff against the CVS version. (Also, there have been other changes that may introduce some incompatibilities.. So a direct drop-in replacement in not advised for the faint-of-heart.)

In the file /wp-includes/functions.php replace lines 1346 & 1347:
$word = trim($word);
$pattern = "#$word#i";

with:
$word = trim($word);
// Skip empty lines
if (empty($word)) { continue; }
$pattern = "#$word#i";

Now, if you accidentally leave a blank line in the words list, it will still behave as expected.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
Sphere: Related Content | stumbleit |

Translate

Translate to German Translate to Spanish Translate to French Translate to Italian Translate to Portuguese Translate to Japanese Translate to Korean Translate to Russian Translate to Chinese

Latest Videos

Latest WordPress Jobs

2 Comments | Leave a comment | Comments RSS

  1. Thanks, put in your fix.

    mog (4 comments.) — 06/1/2004 @ 3:24 pm
  2. [...] Mind of Mog 01.June.04 Fixing Comment Spam Weblog Tools Collection has a fix to the comment spam words bug. One caveat, [...]

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(required)

(required, will not be published)


S2