From 697b439427cd83c2839107a420197bfd5537dc24 Mon Sep 17 00:00:00 2001 From: Gisle Aas Date: Fri, 5 Nov 2004 14:21:29 +0000 Subject: [PATCH] Import of GAAS/URI-1.35 from CPAN. gitpan-cpan-distribution: URI gitpan-cpan-version: 1.35 gitpan-cpan-path: GAAS/URI-1.35.tar.gz gitpan-cpan-author: GAAS gitpan-cpan-maturity: released --- Changes | 13 +++++++++++++ URI.pm | 6 +++++- URI/Escape.pm | 20 ++++++++++++++------ t/escape.t | 4 ++-- t/query.t | 2 +- 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/Changes b/Changes index a1a40cc..b3ef6c7 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,16 @@ +2004-11-05 Gisle Aas + + Release 1.35 + + Documentation update. + + Simplified uri_escape_utf8 implementation. No need to load the + Encode module. Contributed by Alexey Tourbin. + + Work around bug in perl-5.6.0 that made t/query.t fail. + + + 2004-10-05 Gisle Aas Release 1.34 diff --git a/URI.pm b/URI.pm index d33772b..5114ae4 100644 --- a/URI.pm +++ b/URI.pm @@ -2,7 +2,7 @@ package URI; use strict; use vars qw($VERSION); -$VERSION = "1.34"; # $Date: 2004/10/05 08:36:13 $ +$VERSION = "1.35"; # $Date: 2004/11/05 14:17:33 $ use vars qw($ABS_REMOTE_LEADING_DOTS $ABS_ALLOW_RELATIVE_SCHEME); @@ -570,6 +570,10 @@ parameter strings. Such an anonymous array uses overloading so it can be treated as a string too, but this string does not include the parameters. +Note that absolute paths have the empty string as their first +I, i.e. the I C have 3 +I; "", "foo" and "bar". + =item $uri->query =item $uri->query( $new_query ) diff --git a/URI/Escape.pm b/URI/Escape.pm index 49d2a45..5f0de55 100644 --- a/URI/Escape.pm +++ b/URI/Escape.pm @@ -1,5 +1,5 @@ # -# $Id: Escape.pm,v 3.26 2004/04/13 15:17:27 gisle Exp $ +# $Id: Escape.pm,v 3.28 2004/11/05 13:58:31 gisle Exp $ # package URI::Escape; @@ -92,6 +92,13 @@ will be the same as: but will even work for perl-5.6 for chars in the 128 .. 255 range. +Note: Javascript has a function called escape() that produce the +sequence "%uXXXX" for chars in the 256 .. 65535 range. This function +has really nothing to do with URI escaping but some folks got confused +since it "does the right thing" in the 0 .. 255 range. Because of +this you sometimes see "URIs" with these kind of escapes. The +JavaScript encodeURI() function is similar to uri_escape_utf8(). + =item uri_unescape($string,...) Returns a string with each %XX sequence replaced with the actual byte @@ -142,7 +149,7 @@ require Exporter; @ISA = qw(Exporter); @EXPORT = qw(uri_escape uri_unescape); @EXPORT_OK = qw(%escapes uri_escape_utf8); -$VERSION = sprintf("%d.%02d", q$Revision: 3.26 $ =~ /(\d+)\.(\d+)/); +$VERSION = sprintf("%d.%02d", q$Revision: 3.28 $ =~ /(\d+)\.(\d+)/); use Carp (); @@ -179,14 +186,15 @@ sub _fail_hi { sub uri_escape_utf8 { + my $text = shift; if ($] < 5.008) { - my $text = shift; $text =~ s/([^\0-\x7F])/do {my $o = ord($1); sprintf("%c%c", 0xc0 | ($o >> 6), 0x80 | ($o & 0x3f)) }/ge; - return uri_escape($text, @_); + } + else { + utf8::encode($text); } - require Encode; - return uri_escape(Encode::encode_utf8(shift), @_); + return uri_escape($text, @_); } sub uri_unescape diff --git a/t/escape.t b/t/escape.t index 5b3607e..daebd9d 100644 --- a/t/escape.t +++ b/t/escape.t @@ -33,8 +33,8 @@ print "not " unless uri_escape_utf8("|abc print "ok 7\n"; if ($] < 5.008) { - print "ok 8 # skipped\n"; - print "ok 9 # skipped\n"; + print "ok 8 # skip perl-5.8 required\n"; + print "ok 9 # skip perl-5.8 required\n"; } else { eval { print uri_escape("abc" . chr(300)) }; diff --git a/t/query.t b/t/query.t index 89d8699..2918175 100644 --- a/t/query.t +++ b/t/query.t @@ -77,7 +77,7 @@ print "not " unless $u eq ""; print "ok 17\n"; $u->query_form(a => { foo => 1 }); -print "not " unless $u =~ /^\?a=HASH\(/; +print "not " unless "$u" =~ /^\?a=HASH\(/; print "ok 18\n"; __END__