There seems to be a bug in URI::file (from URI-1.18); the host() is not
unescaped as the documentation of URI says.
Here's how to reproduce:
$ perl -MURI -e 'print URI->new("file://foo bar/baz/")->host(), "\n"';
foo%20bar
$
I'd expect
foo bar
....as the output.
Applying this patch does not break tests, but triggers an
Use of uninitialized value in substitution (s///) at
blib/lib/URI/Escape.pm line 161.
....with t/old-base.t. Maybe this should be avoided in URI::Escape?
While I was at it, added a $VERSION to URI/file.pm and trimmed some
trailing whitespace.
--- URI/file.pm~ Fri Apr 7 15:58:06 2000
+++ URI/file.pm Fri Mar 29 03:15:10 2002
@@ -1,10 +1,13 @@
package URI::file;
use strict;
-use vars qw(@ISA);
+use vars qw(@ISA $VERSION);
require URI::_generic;
@ISA = qw(URI::_generic);
+$VERSION = sprintf("%d.%02d", q$Revision: 1.00 $ =~ /(\d+)\.(\d+)/);
+
+use URI::Escape qw(uri_unescape);
# Map from $^O values to implementation classes. The Unix
# class is the default.
@@ -33,7 +36,7 @@
}
sub path { shift->path_query(@_) }
-sub host { shift->authority(@_) }
+sub host { uri_unescape(shift->authority(@_)) }
sub new
{
@@ -89,7 +92,7 @@
$u3 = URI::file->new($path);
$u4 = URI::file->new("c:\\windows\\", "win32");
-
+
$u1->file;
$u1->file("mac");
@@ -213,7 +216,7 @@
<undef> <== /
foo/ <== file:/foo%2F
./foo.txt <== file:/.%2Ffoo.txt
-
+
Note that if you want a relative URL, you *must* begin the path with a :. Any
path that begins with [^:] will be treated as absolute.
Cheers,
--
Ville Skytt�
[EMAIL PROTECTED]