Thanks for indicating the subtle difference.
I've been struggling with this very issue recently and came
across a url here at perlmonks that uri_escape
doesn't handle, and requires CGI::escape. This small CGI
program compares uri_escape and escape by producing two
links to perlmonks:
#!/usr/bin/perl
use CGI qw(:all escape escapeHTML);
use URI::Escape;
$site = 'http://www.perlmonks.org/index.pl?node=';
$user = 'Clive ;-)'; # my test case for whitespace and funny chrs
print header,h1("compare");
print
'<A HREF="',
escapeHTML(uri_escape($site.$user)),
'">',
escapeHTML($user),
'</A> - <tt>escapeHTML(uri_escape($site.$user))</tt><br>'; # does
+n't work
print
'<A HREF="',
escapeHTML($site.escape($user)),
'">',
escapeHTML($user),
'</A> - <tt>escapeHTML($site.escape($user))</tt><p>'; # works
The 1st print using uri_escape on the whole url returns:
http://www.perlmonks.org/index.pl?node=Clive%20;-)
The 2nd print using CGI::escape on the param only, yields:
http://www.perlmonks.org/index.pl?node=Clive%20%3B-%29
As you can see the semicolon is causing a problem in the
uri_escape url.
Is this a general condition or just a peculiarity of
perlmonks?
--
Check out my Perlmonks Related Scripts like framechat,
reputer, and xNN.
|