apply uri_with() patch from Daisuke Murase
Brian Cassidy [Thu, 17 Jan 2008 12:59:07 +0000 (12:59 +0000)]
Changes
lib/Catalyst/Request.pm
t/unit_core_uri_for_multibytechar.t

diff --git a/Changes b/Changes
index 13dec6b..e6b8cd6 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,7 +1,8 @@
 # This file documents the revision history for Perl extension Catalyst.
 
 5.7012  2007-12-16 23:44:00
-       - Fix uri_for()'s handling of multibyte chars (Daisuke Murase)
+        - Fix uri_for()'s and uri_with()'s handling of multibyte chars
+          (Daisuke Murase)
         - Fix __PACKAGE__->config->{foo} = 'bar' case with subclassing
         - Add Catalyst::Stats (Jon Schutz)
         - Fixed a bug where ?q=bar=baz is decoded as q=>'bar', not 'bar=baz'.
index a3ecc6a..50886c0 100644 (file)
@@ -539,7 +539,7 @@ sub uri_with {
         next unless defined $value;
         for ( ref $value eq 'ARRAY' ? @$value : $value ) {
             $_ = "$_";
-            utf8::encode( $_ );
+            utf8::encode( $_ ) if utf8::is_utf8($_);
         }
     };
     
index 0a569d6..f29d6af 100644 (file)
@@ -7,7 +7,7 @@ use lib File::Spec->catfile($FindBin::Bin, 'lib');
 
 use Test::More;
 
-plan tests => 3;
+plan tests => 5;
 
 use_ok('TestApp');
 
@@ -15,6 +15,7 @@ my $base = 'http://127.0.0.1';
 
 my $request = Catalyst::Request->new({
     base => URI->new($base),
+    uri  => URI->new("$base/"),
 });
 
 my $context = TestApp->new({
@@ -30,8 +31,9 @@ $uri_with_multibyte->query_form(
 
 
 # multibyte with utf8 bytes
-is($context->uri_for('/', { name => '村瀬大輔' }), $uri_with_multibyte, 'uri with utf8 bytes query');
-
+is($context->uri_for('/', { name => '村瀬大輔' }), $uri_with_multibyte, 'uri_for with utf8 bytes query');
+is($context->req->uri_with({ name => '村瀬大輔' }), $uri_with_multibyte, 'uri_with with utf8 bytes query');
 
 # multibyte with utf8 string
-is($context->uri_for('/', { name => "\x{6751}\x{702c}\x{5927}\x{8f14}" }), $uri_with_multibyte, 'uri with utf8 string query');
+is($context->uri_for('/', { name => "\x{6751}\x{702c}\x{5927}\x{8f14}" }), $uri_with_multibyte, 'uri_for with utf8 string query');
+is($context->req->uri_with({ name => "\x{6751}\x{702c}\x{5927}\x{8f14}" }), $uri_with_multibyte, 'uri_with with utf8 string query');