From: Brian Cassidy Date: Thu, 17 Jan 2008 12:59:07 +0000 (+0000) Subject: apply uri_with() patch from Daisuke Murase X-Git-Tag: 5.7099_04~95 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=7066a4d53877d5684238582f416ce26a70bdc708 apply uri_with() patch from Daisuke Murase --- diff --git a/Changes b/Changes index 13dec6b..e6b8cd6 100644 --- 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'. diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index a3ecc6a..50886c0 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -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($_); } }; diff --git a/t/unit_core_uri_for_multibytechar.t b/t/unit_core_uri_for_multibytechar.t index 0a569d6..f29d6af 100644 --- a/t/unit_core_uri_for_multibytechar.t +++ b/t/unit_core_uri_for_multibytechar.t @@ -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');