patb - 7:30 am on May 2, 2012 (gmt 0)
Rocknbil and Wiz, thanks for the interest and responses.
Rocknbil: there's more to form spam than just http
Yes, I thought I was going to have to dream up a long and complex regex but your method saved me that.
The code provided by Rocknbil worked well with a change to one line:
my @bad_patterns (
I had to change to:
my @bad_patterns = (
What I experience though is that the headers to the form (email) are still sent whether I use the code I posted earlier or Rocknbil's variation. The offending comments section is deleted but the sender's name and email address as filled in by the sender are still included and sent as an email. It seems the sendmail operation has already started by this point in the script and cannot be stopped.
Rocknbil: I usually choose to log the input and exit the program from the logging routine
Yes. It would be best just to log the offending content somewhere. In such a case, I would prefer that no form were submitted at all. Non-offending forms would be submitted to the relevant person and I would look through the log occasionally to pick up anything falsely identified as spam. That would be my preferred method but right now, a form with spam is truncated but still submitted. I would like to prevent that happening.
Thanks again. Cheers, Pat.