#1 (permalink)  
Old 03-29-2006, 07:48 AM
Registered User
 
Join Date: Mar 2006
Posts: 8
strip carriage returns & linefeed characters from form field

Hi everyone,

I have a little problem with a form to email which is getting spammed, and the solution, I've been told is to strip carriage returns (\r) and linefeed characters (\n) from form fields in my cgi scripts - with the following code:

$field =~ s/\r/ /g;
$field =~ s/\n/ /g;


for each field used in an email.


So, in my code, sample below, what do i change and where!! I tried;

print MAIL "To: $email =~s/\r /g"; but that didnt work...
maybe print MAIL "From: $domain\n\r"; ???


I don't know!!

what should it be?? If someone could amend the code below to include $field =~ s/\r/ /g; & $field =~ s/\n/ /g; for each field used in an email I would be INCREDIBLY grateful!!!

Thanks in advance
amx


CODE below:

sub mailMe
{
my($form,$data) = shift;
my($sendmail,$name,$domain,$email) =
('/usr/lib/sendmail','Mann Scuba Divers','www.mydomain.co.uk','myemail@gmail.com, myemail@hotmail.com');
open MAIL, "|$sendmail $email" or die "Can't open sendmail: message = '$!'";
print MAIL "To: $email\n";
print MAIL "From: $domain\n";
print MAIL "Subject: $form->{subject}\n\n";
print MAIL "Dear $name,\n\n";
for(@{$form->{Seq}}) { print MAIL "$_\t\t : ",$form->{$_},"\n" and $data = 1 }
print MAIL "The input form was empty\n" unless $data;
print MAIL "\n\nYours truly,\nThe Mail Room";
close MAIL or die "Can't close sendmail: message = '$!'"
}
Reply With Quote

  #2 (permalink)  
Old 03-29-2006, 12:06 PM
Till's Avatar
Administrator
 
Join Date: Jan 2002
Location: Berlin, Germany
Posts: 1,453
Most likely the problem is the following:

The $email variable could contain not just one email address, but 4, 5, or however many are put in through this attack. Isn't that the issue? Also, I see that you can feed in other headers (CC:/BCC: as well through this.

Let me know,
Till
Reply With Quote
  #3 (permalink)  
Old 03-30-2006, 07:52 AM
Registered User
 
Join Date: Mar 2006
Posts: 8
thanks...

how do i fix it?!

cheers
amx
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
targeting hidden input field in form beba Programming and Scripting 2 12-03-2005 10:22 AM
Store Form Focus As Variable? curtiss Programming and Scripting 1 09-30-2005 10:41 AM
Using a variable as defaut value in form field dilbertza2 Programming and Scripting 1 04-17-2005 12:03 PM


All times are GMT -5. The time now is 04:58 PM.

 
Bitrix
Clicky Web Analytics
CloudContacts
Maxtango


Subscribe to our feed | add to myYahoo!

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
© 1997-2007 HTMLCenter