Forum Moderators: coopster & phranque

Message Too Old, No Replies

HTML Entities

HTML Entities causing interference

         

typomaniac

7:03 pm on May 18, 2022 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi, I'm not sure if I got the Meta description spot on but here's my situation:
On a contact form processor I have the following scenario

my $field_name = HTML::Entities::encode($field_name); 
which is supposed to prevent users from using quotes. The problem is, when it prints the email it appears as such:
if user used a double quote it would be like for quote"s sake whereas a single prints out in the order of Tom's
Is it really all that important to eliminate quotes and if so, how do I get them back in the string for the email body. I think what I'm trying to say is how do I get the message to look like the way it was originally submitted?

typomaniac

1:50 pm on May 20, 2022 (gmt 0)

10+ Year Member Top Contributors Of The Month



I got this one taken care of. I appreciate anyone who took time to read it though.

Brett_Tabke

4:11 pm on May 20, 2022 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



What was you solution?

I use HTML::Entities here to convert/deconvert titles and descriptions from featured images in posts. Since that is coming from a third party, we really can't control the content of those entities and have to get aggressive about filtering it.

typomaniac

7:57 pm on May 20, 2022 (gmt 0)

10+ Year Member Top Contributors Of The Month



I didn't know it would deconvert the quotes. I was deconverting with

$var =~s/'/\'/;

I'll have to give that a try. I appreciate that.

Brett_Tabke

2:53 am on Jun 27, 2022 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Ya, that is one of it's prime uses:

use HTML::Entities;

my $htm = "Fun times & Good Friends";

print decode_entities($htm), "\n";