[Catalyst-dev] uri_for method is broken in latest release
Daisuke Murase
typester at cpan.org
Thu Jan 17 02:23:32 GMT 2008
On Wed, Jan 16, 2008 at 08:37:03 -0400, Brian Cassidy wrote:
> Does this mean that req->uri_with() is also broken?
Right, I did quick review and found it was also broken.
So I wrote a patch again (against trunk 5.70, attached)
The point at this problem is that calling utf8::encode/decode without
checking utf8::is_utf8 is harmful.
--
Daisuke Murase <typester at cpan.org>
-------------- next part --------------
Index: t/unit_core_uri_for_multibytechar.t
===================================================================
--- t/unit_core_uri_for_multibytechar.t (revision 7399)
+++ t/unit_core_uri_for_multibytechar.t (working copy)
@@ -7,7 +7,7 @@
use Test::More;
-plan tests => 3;
+plan tests => 5;
use_ok('TestApp');
@@ -15,6 +15,7 @@
my $request = Catalyst::Request->new({
base => URI->new($base),
+ uri => URI->new("$base/"),
});
my $context = TestApp->new({
@@ -30,8 +31,9 @@
# 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');
Index: lib/Catalyst/Request.pm
===================================================================
--- lib/Catalyst/Request.pm (revision 7399)
+++ lib/Catalyst/Request.pm (working copy)
@@ -539,7 +539,7 @@
next unless defined $value;
for ( ref $value eq 'ARRAY' ? @$value : $value ) {
$_ = "$_";
- utf8::encode( $_ );
+ utf8::encode( $_ ) if utf8::is_utf8($_);
}
};
More information about the Catalyst-dev
mailing list