X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=dd44d0f9e625f57ff9a60f76b612b821f78c0371;hb=52e23ad416cd9765e675dcedd7d123f0e9523ca7;hp=25f4caf91b9345e65206a5269c9e8f70a0fcb339;hpb=1bebcac61bb8a8decc34b48cf823b5004c32fd9c;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 25f4caf..dd44d0f 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -1265,6 +1265,9 @@ sub uri_for { ( 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; if (blessed $path) { # Action object only. s|/|%2F|g for @args; @@ -1275,6 +1278,12 @@ sub uri_for { ( 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) { @@ -1285,6 +1294,8 @@ sub uri_for { $path = '/' if $path eq ''; } + undef($path) if (defined $path && $path eq ''); + unshift(@args, $path); unless (defined $path && $path =~ s!^/!!) { # in-place strip