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

encode_entities for sendmail

by tomazos (Deacon)
on Aug 18, 2005 at 12:43 UTC ( [id://484732]=perlquestion: print w/replies, xml ) Need Help??

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

I am automating an email with text from an untrusted scalar $body.

use HTML::Entities; open MAIL, q(|/usr/lib/sendmail -t -f 'bar@bar.com') or die 'cant open sendmail'; print MAIL "From: foo <bar\@bar.com>\n"; print MAIL "To: boo <far\@far.com>\n"; print MAIL "\n"; print MAIL encode_entities($body),"\n"; print MAIL ".\n"; close MAIL;

The encode_entities is clearly overkill.

Is there an equivilant for whatever encoding is correct for email? Or would no encoding be safe even though $body is untrusted?

-Andrew.


Andrew Tomazos  |  andrew@tomazos.com  |  www.tomazos.com

Replies are listed 'Best First'.
Re: encode_entities for sendmail
by jasonk (Parson) on Aug 18, 2005 at 13:05 UTC

    It really depends more on what the receivers of the email are doing with it. Not encoding with anything would be plenty safe for most mail clients that don't render HTML, running it through encode_entities would probably protect most of those that do render HTML, and even running it through s/\W// may not make it safe enough for Outlook...


    We're not surrounded, we're in a target-rich environment!
Re: encode_entities for sendmail
by merlyn (Sage) on Aug 18, 2005 at 14:01 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-24 21:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found