Jump to content


Photo

comment spam regexes failing


  • Please log in to reply
2 replies to this topic

#1 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 08 September 2006 - 02:44 AM

I'm running the comment spam catcher that's exactly as shown at http://www.imarc.net..._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):

$total_matches += 5 * preg_match_all($regex, $text, $trash);

Anyone care to point out the corrective action needed, or point me to an effective alternative?
Legend has it that reading the manual never killed anyone.
My site

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 08 September 2006 - 03:14 AM

Since / is the delimiter, any /'s in the pattern must be escaped: /[\s*/\s*url\s*]/i. Even with that escaped, I still don't agree with the pattern: the [ ]'s are not escaped, therefore specifying a character class instead of actual braces. All they should need for counting the links is / \ [ url =/ i at the bare minimum. (Spaces were added so this forum would not interpret it as bbcode.)
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 08 September 2006 - 05:36 PM

Thanks, effigy. That's taken care of the error.
Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users