Closed p5pRT closed 20 years ago
It was written in perlfaq9 that
s/([^\w()'*~!.-])/sprintf '%%%02x'\, $1/eg; # encode
is how you create %-encodings on the web. This doesn't work because sprintf is expecting numeric value. I've included a patch below. :-)
[sherwin@saturn sherwin]$ perl illustratebug.pl Argument ":" isn't numeric in sprintf at testbug.pl line 5. Argument "/" isn't numeric in sprintf at testbug.pl line 5. Argument "/" isn't numeric in sprintf at testbug.pl line 5. Argument "/" isn't numeric in sprintf at testbug.pl line 5. Argument "/" isn't numeric in sprintf at testbug.pl line 5. Argument " " isn't numeric in sprintf at testbug.pl line 5. Argument "/" isn't numeric in sprintf at testbug.pl line 5. Argument "#" isn't numeric in sprintf at testbug.pl line 5. http%00%00%00foo.bar%00baz%00foo%00bar%00%0021028461
# --- BEGIN illustratebug.pl
#!/usr/bin/perl -w use strict; (my $s = 'http://foo.bar/baz/foo bar/#21028461') =~ s/([^\w()'*~!\.-])/sprintf '%%%02x'\, $1/eg; print "$s\n"; exit 0;
# --- END illustratebug.pl
# --- BEGIN perlfaq9.pod.patch
*** perl-5.6.1/pod/perlfaq9.pod.orig Sun Apr 8 14:09:16 2001 --- perl-5.6.1/pod/perlfaq9.pod Wed Apr 24 20:29:57 2002 *************** *** 219\,227 **** The best source of detailed information on URI encoding is RFC 2396. Basically\, the following substitutions do it:
! s/([^\w()'*~!.-])/sprintf '%%%02x'\, $1/eg; # encode
! s/%([A-Fa-f\d]{2})/chr hex $1/eg; # decode
However\, you should only apply them to individual URI components\, not the entire URI\, otherwise you'll lose information and generally mess --- 219\,227 ---- The best source of detailed information on URI encoding is RFC 2396. Basically\, the following substitutions do it:
! s/([^\w()'*~!.-])/sprintf '%%%02x'\, ord $1/eg; # encode
! s/%([A-Fa-f\d]{2})/chr hex $1/eg; # decode
However\, you should only apply them to individual URI components\, not the entire URI\, otherwise you'll lose information and generally mess
# --- END perlfaq9.pod.patch
On Wed\, Apr 24\, 2002 at 09:45:45PM +0800\, Sherwin Daganato wrote:
This is a bug report for perl from win@email.com.ph\, generated with the help of perlbug 1.33 running under perl v5.6.1.
It seems that this bug has been already corrected in the latest version of the FAQ (http://faq.perl.org/perlfaq9\, the HTML formatting seems to be a bit off\, but the ord() is there.)
-- $jhi++; # http://www.iki.fi/jhi/ # There is this special biologist word we use for 'stable'. # It is 'dead'. -- Jack Cohen
Migrated from rt.perl.org#9009 (status was 'resolved')
Searchable as RT9009$