[Catalyst-commits] r6873 - in trunk/Catalyst-Runtime: lib/Catalyst t

miyagawa at dev.catalyst.perl.org miyagawa at dev.catalyst.perl.org
Thu Sep 13 01:17:51 GMT 2007


Author: miyagawa
Date: 2007-09-13 01:17:51 +0100 (Thu, 13 Sep 2007)
New Revision: 6873

Modified:
   trunk/Catalyst-Runtime/lib/Catalyst/Engine.pm
   trunk/Catalyst-Runtime/t/live_engine_request_parameters.t
Log:
fix the bug Catalyst::Engine double decodes %2b back to ' ' (space)

Modified: trunk/Catalyst-Runtime/lib/Catalyst/Engine.pm
===================================================================
--- trunk/Catalyst-Runtime/lib/Catalyst/Engine.pm	2007-09-12 17:15:54 UTC (rev 6872)
+++ trunk/Catalyst-Runtime/lib/Catalyst/Engine.pm	2007-09-13 00:17:51 UTC (rev 6873)
@@ -658,10 +658,9 @@
 
 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;
 }
 

Modified: trunk/Catalyst-Runtime/t/live_engine_request_parameters.t
===================================================================
--- trunk/Catalyst-Runtime/t/live_engine_request_parameters.t	2007-09-12 17:15:54 UTC (rev 6872)
+++ trunk/Catalyst-Runtime/t/live_engine_request_parameters.t	2007-09-13 00:17:51 UTC (rev 6873)
@@ -6,7 +6,7 @@
 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,7 +39,17 @@
 
 {
     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)],
         '%'     => [ '%', '"', '& - &' ],




More information about the Catalyst-commits mailing list