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.
In reply to HTML::Entities not encoding @ or . by punch_card_don
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |