Re: Base64 data: URLs vs url encoding

2006-04-19 Thread Gisle Aas
Bjoern Hoehrmann <[EMAIL PROTECTED]> writes:

> Hi,
> 
>   print URI->new('data:;base64,QmpvZXJu')->data;
>   print URI->new('data:;base64,%51%6D%70%76%5A%58%4A%75')->data;
> 
> I think this should both print "Bjoern", but in the second case the
> module returns garbage (URI 1.35).

Thanks for your report.  I've applied the following patch to fix this
bug:

Index: URI/data.pm
===
RCS file: /cvsroot/libwww-perl/uri/URI/data.pm,v
retrieving revision 4.4
diff -u -p -r4.4 data.pm
--- URI/data.pm 14 Jan 2004 13:33:44 -  4.4
+++ URI/data.pm 19 Apr 2006 11:01:01 -
@@ -55,7 +55,8 @@ sub data
$self->opaque("$enc,$new");
 }
 return unless defined wantarray;
-return $base64 ? decode_base64($data) : uri_unescape($data);
+$data = uri_unescape($data);
+return $base64 ? decode_base64($data) : $data;
 }
 
 # I could not find a better way to interpolate the tr/// chars from
Index: t/data.t
===
RCS file: /cvsroot/libwww-perl/uri/t/data.t,v
retrieving revision 1.4
diff -u -p -r1.4 data.t
--- t/data.t5 Aug 2003 15:27:49 -   1.4
+++ t/data.t19 Apr 2006 11:01:01 -
@@ -9,7 +9,7 @@ if ($@) {
 exit;
 }
 
-print "1..21\n";
+print "1..22\n";
 
 use URI;
 
@@ -106,3 +106,5 @@ $old = $u->data("new");
 print "not " unless $old eq "" && $u eq "data:bar%2Cb%E5z,new";
 print "ok 21\n";
 
+print "not " unless URI->new('data:;base64,%51%6D%70%76%5A%58%4A%75')->data eq 
"Bjoern";
+print "ok 22\n";


Base64 data: URLs vs url encoding

2006-04-18 Thread Bjoern Hoehrmann
Hi,

  print URI->new('data:;base64,QmpvZXJu')->data;
  print URI->new('data:;base64,%51%6D%70%76%5A%58%4A%75')->data;

I think this should both print "Bjoern", but in the second case the
module returns garbage (URI 1.35).

regards,
-- 
Björn Höhrmann · mailto:[EMAIL PROTECTED] · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/