Jump to content

comment spam regexes failing


AndyB

Recommended Posts

I'm running the comment spam catcher that's exactly as shown at http://www.imarc.net/blog/61/stopping_blog_comment_spam_with_php/

Can't post the code here because the IPS rejects the post  :o

When I have a plain text string without any of the 'common spam' words, it works.  As soon as I include a common spam word, it throws a Warning: Unknown modifier '\' in c:\phpdev\www\ ... on line 33 (which is the line in the phpBB links section):

[code]$total_matches += 5 * preg_match_all($regex, $text, $trash);[/code]

Anyone care to point out the corrective action needed, or point me to an effective alternative?
Link to comment
https://forums.phpfreaks.com/topic/20081-comment-spam-regexes-failing/
Share on other sites

Since[tt] / [/tt] is the delimiter, any[tt] /[/tt]'s in the pattern must be escaped: [tt]/[\s*[b]/[/b]\s*url\s*]/i[/tt]. Even with that escaped, I still don't agree with the pattern: the [tt][ ][/tt]'s are not escaped, therefore specifying a character class instead of actual braces. All they should need for counting the links is [tt]/ \ [ url =/ i[/tt] at the bare minimum. (Spaces were added so this forum would not interpret it as bbcode.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.