From: Tatsuhiko Miyagawa Date: Thu, 13 Sep 2007 00:17:51 +0000 (+0000) Subject: fix the bug Catalyst::Engine double decodes %2b back to ' ' (space) X-Git-Tag: 5.7099_04~137 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=7d22a5373b8e3c57c1c6a9cae3d246efb840a8ea fix the bug Catalyst::Engine double decodes %2b back to ' ' (space) --- diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index c53bc12..089a959 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -658,10 +658,9 @@ as Apache may implement this using Apache's C-based modules, for example. sub unescape_uri { my ( $self, $str ) = @_; - - $str =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg; - $str =~ s/\+/ /g; - + + $str =~ s/(?:%([0-9A-Fa-f]{2})|\+)/defined $1 ? chr(hex($1)) : ' '/eg; + return $str; } diff --git a/t/live_engine_request_parameters.t b/t/live_engine_request_parameters.t index 851d4c5..1f1091f 100644 --- a/t/live_engine_request_parameters.t +++ b/t/live_engine_request_parameters.t @@ -6,7 +6,7 @@ use warnings; use FindBin; use lib "$FindBin::Bin/lib"; -use Test::More tests => 30; +use Test::More tests => 35; use Catalyst::Test 'TestApp'; use Catalyst::Request; @@ -39,6 +39,16 @@ use URI; { my $creq; + ok( my $response = request("http://localhost/dump/request?q=foo%2bbar"), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + ok( eval '$creq = ' . $response->content ); + is $creq->{parameters}->{q}, 'foo+bar', '%2b not double decoded'; +} + +{ + my $creq; my $parameters = { 'a' => [qw(A b C d E f G)],