in reply to Dump a directory as links from CGI
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Dump a directory as links from CGI
by merlyn (Sage) on May 31, 2001 at 02:39 UTC | |
by epoptai (Curate) on May 31, 2001 at 06:51 UTC | |
by merlyn (Sage) on May 31, 2001 at 07:02 UTC | |
by cLive ;-) (Prior) on Jun 03, 2001 at 03:35 UTC |