[Catalyst-commits] r12538 - in
Catalyst-Runtime/5.80/branches/uri_for_utf8: lib t/aggregate
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Wed Jan 6 22:56:59 GMT 2010
Author: caelum
Date: 2010-01-06 22:56:59 +0000 (Wed, 06 Jan 2010)
New Revision: 12538
Modified:
Catalyst-Runtime/5.80/branches/uri_for_utf8/lib/Catalyst.pm
Catalyst-Runtime/5.80/branches/uri_for_utf8/t/aggregate/live_component_controller_action_chained.t
Log:
utf8::decode captures and args, and uri-escape captures
Modified: Catalyst-Runtime/5.80/branches/uri_for_utf8/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/uri_for_utf8/lib/Catalyst.pm 2010-01-06 22:33:51 UTC (rev 12537)
+++ Catalyst-Runtime/5.80/branches/uri_for_utf8/lib/Catalyst.pm 2010-01-06 22:56:59 UTC (rev 12538)
@@ -1251,6 +1251,12 @@
( scalar @args && ref $args[0] eq 'ARRAY'
? @{ shift(@args) }
: ()) ];
+
+ foreach my $capture (@$captures) {
+ utf8::encode($capture) if utf8::is_utf8($capture);
+ $capture =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go;
+ }
+
my $action = $path;
$path = $c->dispatcher->uri_for_action($action, $captures);
if (not defined $path) {
@@ -1267,6 +1273,10 @@
( scalar @args && ref $args[$#args] eq 'HASH' ? pop @args : {} );
carp "uri_for called with undef argument" if grep { ! defined $_ } @args;
+
+ foreach my $arg (@args) {
+ utf8::encode($arg) if utf8::is_utf8($arg);
+ }
s/([^$URI::uric])/$URI::Escape::escapes{$1}/go for @args;
s|/|%2F| for @args;
@@ -1301,7 +1311,6 @@
(map {
my $param = "$_";
utf8::encode( $param ) if utf8::is_utf8($param);
- # using the URI::Escape pattern here so utf8 chars survive
$param =~ s/([^A-Za-z0-9\-_.!~*'() ])/$URI::Escape::escapes{$1}/go;
$param =~ s/ /+/g;
"${key}=$param"; } ( ref $val eq 'ARRAY' ? @$val : $val ));
Modified: Catalyst-Runtime/5.80/branches/uri_for_utf8/t/aggregate/live_component_controller_action_chained.t
===================================================================
--- Catalyst-Runtime/5.80/branches/uri_for_utf8/t/aggregate/live_component_controller_action_chained.t 2010-01-06 22:33:51 UTC (rev 12537)
+++ Catalyst-Runtime/5.80/branches/uri_for_utf8/t/aggregate/live_component_controller_action_chained.t 2010-01-06 22:56:59 UTC (rev 12538)
@@ -1074,6 +1074,7 @@
['foo%2Fbar', 'baz%2Fquux'],
['foo%2Fbar', 'baz%2Fquux', { foo => 'bar', 'baz' => 'quux%2Ffrood'}],
['foo%2Fbar', 'baz%2Fquux', { foo => 'bar', 'baz%2Ffnoo' => 'quux%2Ffrood'}],
+ ['h%C3%BCtte', 'h%C3%BCtte', { test => 'h%C3%BCtte' } ],
) {
my $path = '/chained/roundtrip_urifor/' .
$thing->[0] . '/' . $thing->[1];
@@ -1085,7 +1086,8 @@
'request ' . $path . ' ok');
# Just check that the path matches, as who the hell knows or cares
# where the app is based (live tests etc)
- ok( index($content, $path) > 1, 'uri can round trip through uri_for' );
+ ok( index($content, $path) > 1, 'uri can round trip through uri_for' )
+ or diag "'$content' does not contain '$path'";
}
}
More information about the Catalyst-commits
mailing list