Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Escaping html tags in html mail

Status
Not open for further replies.

JNameNotTaken

Programmer
Aug 29, 2006
24
0
0
IE
Hello All

New problem today. Any help would be great, thanks.

I have a form that takes text from a user in a Text Area and sends it as part of the body of a html mail.

Firstly, I replace all the \n's with <BR>'s on the text from the text area as so:
Code:
$detailsBR = $details;
$detailsBR =~ s/\n/<BR>/g;
All is well.

However if a user enters a html tag e.g. <object> in the text, the rendered email stops right there before the <. i.e. characters are missing.
I can only assume it's because a corresponding </object> or whatever tag is expected. If I manually provide a corresponding closing tag it resolves the issue but obviously the text "<object>" is missing.

Is their any easy way to fix this? I looked into URI::Escape; but it adds padding for spaces and stuff like that which is not what I need.

Any ideas how to escape html from the mail?

Oh, and putting <code> </code> tags around the text did not work for some reason. Perhaps the email recipient renderer does not recognize the code tag? (no idea!)

Thanks Very Much
 
ok here is how it's done/fixed:

Code:
use CGI qw/:standard/;
my $HTMLEscapedText = escapeHTML( $htmlText );

Bye.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top