Subject: | Catalyst dev server converts encoded '+' (%2B) into spaces in query string. |
All '+' symbols in form inputs with request method 'GET' are converted
to spaces in catalyst dev server.
For example (C++ developer)
/product/search?query=C%2B%2B+developer
$c->req->param('query') == 'C developer';
Patch and test patch are attached.
Subject: | Catalyst-Engine-pm_diff.txt |
--- Catalyst-Runtime-5.7010-JaQZZ3/lib/Catalyst/Engine.pm Wed Aug 22 09:43:27 2007
+++ Catalyst-Runtime-5.7010-fixed/lib/Catalyst/Engine.pm Thu Oct 18 12:08:41 2007
@@ -654,8 +654,8 @@
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})/chr(hex($1))/eg;
return $str;
}
Subject: | live_engine_request_uri-t_diff.txt |
--- Catalyst-Runtime-5.7010-JaQZZ3/t/live_engine_request_uri.t Wed Aug 22 09:43:26 2007
+++ Catalyst-Runtime-5.7010-fixed/t/live_engine_request_uri.t Thu Oct 18 12:11:05 2007
@@ -6,7 +6,7 @@
use FindBin;
use lib "$FindBin::Bin/lib";
-use Test::More tests => 44;
+use Test::More tests => 49;
use Catalyst::Test 'TestApp';
use Catalyst::Request;
@@ -58,6 +58,15 @@
ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
is( $creq->{uri}->query, 'text=Catalyst%20Rocks', 'Query string ok' );
is( $creq->{parameters}->{text}, 'Catalyst Rocks', 'Unescaped param ok' );
+}
+
+# test that query params are unescaped properly with '+'
+{
+ ok( my $response = request('http://localhost/engine/request/uri?text=C%2B%2B+lang'), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
+ is( $creq->{uri}->query, 'text=C%2B%2B+lang', 'Query string ok' );
+ is( $creq->{parameters}->{text}, 'C++ lang', 'Unescaped param ok' );
}
# test that uri_with adds params