my @parts = split('/', $path);
my ($chain, $captures, $parts) = $self->recurse_match($c, '/', \@parts);
- push @{$request->args}, @$parts if $parts && @$parts;
+
+ if ($parts && @$parts) {
+ for my $arg (@$parts) {
+ $arg =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
+ push @{$request->args}, $arg;
+ }
+ }
return 0 unless $chain;
and the URI for the request was C<http://.../foo/moose/bah>, the string C<bah>
would be the first and only argument.
-Arguments just get passed through and B<don't> get unescaped automatically, so
-you should do that explicitly.
+Arguments get automatically URI-unescaped for you.
=head2 $req->args
BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
-use Test::More tests => 145*$iters;
+use Test::More tests => 147*$iters;
use Catalyst::Test 'TestApp';
if ( $ENV{CAT_BENCHMARK} ) {
ok( my $content =
get('http://localhost/chained/return_arg/foo%2Fbar%3B'),
'request with URI-encoded arg' );
- # this is the CURRENT behavior
- like( $content, qr{foo%2Fbar%3B\z}, 'args NOT decoded' );
+ like( $content, qr{foo/bar;\z}, 'args decoded' );
+ }
+ {
+ ok( my $content =
+ get('http://localhost/chained/return_arg_decoded/foo%2Fbar%3B'),
+ 'request with URI-encoded arg' );
+ like( $content, qr{foo/bar;\z}, 'args decoded' );
}
}
+
use strict;
use warnings;
+use HTML::Entities;
+
use base qw/Catalyst::Controller/;
sub begin :Private { }
sub doc_star : Chained('/') PathPart('chained/doc') Args(1) {}
sub return_arg : Chained('/') PathPart('chained/return_arg') Args(1) {}
+sub return_arg_decoded : Chained('/') PathPart('chained/return_arg_decoded') Args(1) {
+ my ($self, $c) = @_;
+ $c->req->args([ map { decode_entities($_) } @{ $c->req->args }]);
+}
+
sub end :Private {
my ($self, $c) = @_;