Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Blocking Inappropriate Content on Contact Form

by Milti (Sexton)
on Jul 19, 2022 at 14:48 UTC ( #11145586=perlquestion: print w/replies, xml ) Need Help??

Milti has asked for the wisdom of the Perl Monks concerning the following question:

I have a Perl program on my server to prevent certain words being used when my contact form is submitted. For the most part it is working but a single "spammer" has somehow found a way around it. Here is the code.

$String=param('Message'); if ($String =~ /porn/) { print "<p><font size=+4\">Goodbye</font></p>"; exit;} if ($String =~ /sex/) { print "<p><font size=+4\">Goodbye</font></p>"; exit;} if ($String =~ /girls/ ) { print "<p><font size=+4\">Goodbye</font></p>"; exit;}

The rest of the program checks for "Not a Robot", Enter Anti Spam number, etc and then forwards the message to my email service. When I get an inappropriate message I can copy it and paste in my contact form and the message will not be sent, i.e. I get a "Goodbye" return. How can this be? How is the spammer getting by my safeguards?

Any and all help will be appreciated. Tks!

Replies are listed 'Best First'.
Re: Blocking Inappropriate Content on Contact Form
by afoken (Chancellor) on Jul 19, 2022 at 16:03 UTC
    if ($String =~ /sex/) {

    What's wrong with "Greetings from Essex"?

    The rest of the program checks for "Not a Robot", Enter Anti Spam number, etc and then forwards the message to my email service. [...] How can this be? How is the spammer getting by my safeguards?

    By using the email service directly, bypassing those trivial checks?

    Add some logging, especially log $String (plus date plus remote IP). If you still get spam, but find no traces in the log, that's what happened.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      What's wrong with "Greetings from Essex"?

      ... or, indeed, from Scunthorpe?


      Give a man a fish:  <%-{-{-{-<

        my lols woke up the poor whakers!

Re: Blocking Inappropriate Content on Contact Form
by haukex (Archbishop) on Jul 19, 2022 at 15:10 UTC
    How is the spammer getting by my safeguards?

    You'd need to post the actual, raw data you're receiving in order for us to be able to tell, along with code (SSCCE). Perhaps they're using some Unicode characters (that don't survive your copy&paste)? See all the advice you got in your last thread Bad Language In Contact Messages.

Re: Blocking Inappropriate Content on Contact Form
by bliako (Monsignor) on Jul 19, 2022 at 19:49 UTC

    Perhaps they think all these inappropriate content deserve to be Capitalised? (edit: adding a second version: perhaps these inappropriate content is Capitalised in their books?) $String =~ /girls/i

    bw, bliako

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11145586]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2022-12-08 07:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?