punch_card_don has asked for the wisdom of the Perl Monks concerning the following question:
Follow up to this question - my Perl script uses HTML::Entities to encode form input for sql sanitization on fields like fname, lname, email, address1, etc.
I asked the question above after noticing that the at-sign (@) and the period (.) were not being encoded. I thought maybe these were not in the default list %char2entity.
So I did this (only the pertinent lines shown):
use HTML::Entities; use HTML::Entities qw( %char2entity %entity2char ); #thanks ikegami foreach $val (keys %char2entity) { print "<br>$val => $char2entity{$val}\n"; } $string = "this is an @ AT"; $string_2 = "é â ä à å ç ê ë è ï î ì Ä å É æ Æ ô ö ò û ù ÿ Ö Ü £ ¥ P ƒ + á í ó ú ñ Ñ ª º ¿ ¬ ¬ ½ ¼ ¡ @ . , < > [ ] { } - _ ; :"; print "<p>encoded @ => ".encode_entities('@').", <br>and the string ha +s become => ".encode_entities($string)." <br>and the string_2 has bec +ome => ".encode_entities($string_2)."\n";
And I get the same result running this by telnet to ensure I'm not looking at interpreted output.... <br>@ => @ ... <br>. => . ... encoded @ => @, <br>and the string has become => this is an @ AT <br>and the string_2 has become => é â ä à &a +ring; ç ê ë è ï î ì Ä + å É æ Æ ô ö ò û &ug +rave; ÿ Ö Ü £ ¥ P ƒ á í & +oacute; ú ñ Ñ ª º ¿ ¬ ¬ + ½ ¼ ¡ @ . , < > [ ] { } - _ ; :
The @ and the . are right there in the hash of characters to encode. But they are not encoded. Note that several other characters that I also found in the hash are not encoded, such as [ and ].
What the heck?
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTML::Entities not encoding @ or .
by moritz (Cardinal) on Feb 12, 2008 at 14:04 UTC | |
|
Re: HTML::Entities not encoding @ or .
by Joost (Canon) on Feb 12, 2008 at 14:25 UTC | |
by punch_card_don (Curate) on Feb 12, 2008 at 14:30 UTC | |
by Joost (Canon) on Feb 12, 2008 at 16:25 UTC | |
by Errto (Vicar) on Feb 12, 2008 at 19:46 UTC | |
|
Re: HTML::Entities not encoding @ or .
by Anonymous Monk on Feb 12, 2008 at 14:05 UTC | |
|
Re: HTML::Entities not encoding @ or .
by punch_card_don (Curate) on Feb 12, 2008 at 14:21 UTC | |
by Anonymous Monk on Feb 12, 2008 at 16:19 UTC | |
by punch_card_don (Curate) on Feb 12, 2008 at 16:53 UTC | |
by Anonymous Monk on Feb 14, 2008 at 12:53 UTC |