I have tried reading up on security. I want to make sure my code is ok though. I am a Perl novice and have learned by looking at other code. Any help would be MOST helpful. I do not want to help spammers. OK, this is what I use to email stuff back to me from my website:

#The emailing part:

sub sendMail { $email = $FORM{'Email'} ; if (length $email > 80) { &Show_Critical_Error ('Email Address too long!'); } if ($email =~ /^[^@]+@([-\w]+\.)+[A-Za-z]{2,4}$/) { open(MAIL, "|$email_path -t -oi -odq") || &Show_Critical_Error('Sy +stem Error. Unable to open mail application.') ; print MAIL "To: myemail\@mydomain.com(my domain name)\n" ; print MAIL "From: $FORM{'Email'} (JazzKids SITE)\n" ; print MAIL "Subject: WEBSITE CONTACT-jazzkids\n" ; print MAIL "\n" ; print MAIL "Name: $FORM{'Name'}\n\n" ; print MAIL "Email: $FORM{'Email'}\n\n" ; print MAIL "Address: $FORM{'Address'}\n\n" ; print MAIL "City: $FORM{'City'}\n\n" ; print MAIL "State: $FORM{'State'}\n\n" ; print MAIL "Zip: $FORM{'Zip'}\n\n" ; print MAIL "Specialty: $FORM{'Specialty'}\n\n" ; print MAIL "Best to reach by: $FORM{'Reachby'}\n\n" ; print MAIL "Best to reach when: $FORM{'Reachwhen'}\n\n" ; print MAIL "Comments: $FORM{'Comments'}\n\n" ; print MAIL "----------------------------------------\n\n" ; print MAIL "Sent from: $FORM{'form'}\n\n" ; close(MAIL) ; } else {&Show_Critical_Error('EMAIL ADDRESS INVALID.') ;} }
#The parsing part:

sub Parse_Post_Form { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}) ; @pairs = split(/&/, $buffer) ; $valid = "[A-Za-z]\@\:\." ; foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair) ; $value =~ tr/+/ / ; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg ; $value =~ s/[^$valid]/./go; $FORM{$name} = $value ; if ($value =~ s/`//) { &Show_Critical_Error ('No back ticks allowed!'); } } }
THANKS for any help!!


SORRY IF THIS IS A DUPE!

Edit by castaway - removed extra br tags inside code tags

Considered by VSarkiss: Delete: dup of Reaped: Perl Security which has replies
Unconsidered by Arunbear: keep votes prevented reaping; Keep/Edit/Delete: 15/5/18


In reply to Perl Security - Prevent SPAM by jazzwill

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.