I've noticed that CGI::escape is similar to uri_escape and have been using it successfully to avoid using URI::Escape when CGI is already imported. My tests show that CGI::escape also encodes characters like ! and ? that uri_escape leaves alone.
Here's the relevant source code from CGI.pm escape()
and here's the code from URI::Escape uri_escape()$toencode=~s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",ord($1))/eg;
My question: Is it safe to use CGI::escape instead of uri_escape?# Build a char->hex map for (0..255) { $escapes{chr($_)} = sprintf("%%%02X", $_); } $text =~ s/([^;\/?:@&=+\$,A-Za-z0-9\-_.!~*'()])/$escapes{$1}/g;
--
Check out my Perlmonks Related Scripts like framechat,
reputer, and xNN.
In reply to Re: Dump a directory as links from CGI
by epoptai
in thread Dump a directory as links from CGI
by merlyn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |