query param encoding patch
Marcus Ramberg [Fri, 9 May 2008 17:04:23 +0000 (17:04 +0000)]
Changes
lib/Catalyst.pm
t/unit_core_uri_for.t

diff --git a/Changes b/Changes
index 75648c8..afb5adc 100644 (file)
--- a/Changes
+++ b/Changes
@@ -10,6 +10,7 @@
         - Fix grammar on welcome page (RT #33236)
         - Fix for Path('0') handling (RT #29334)
         - Workaround for Win32 and c3_mro.t (RT #26452, tested by Kenichi Ishigaki)
+        - Fix for encoding query parameters (eden)
 
 5.7012  2007-12-16 23:44:00
         - Fix uri_for()'s and uri_with()'s handling of multibyte chars
index 749d567..2bc2227 100644 (file)
@@ -974,10 +974,10 @@ sub uri_for {
     if (my @keys = keys %$params) {
       # somewhat lifted from URI::_query's query_form
       $query = '?'.join('&', map {
+          my $val = $params->{$_};
           s/([;\/?:@&=+,\$\[\]%])/$URI::Escape::escapes{$1}/go;
           s/ /+/g;
           my $key = $_;
-          my $val = $params->{$_};
           $val = '' unless defined $val;
           (map {
               $_ = "$_";
index 0c61435..c767ff2 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 14;
+use Test::More tests => 15;
 use URI;
 
 use_ok('Catalyst');
@@ -58,6 +58,11 @@ is(
     'http://127.0.0.1/foo/yada/quux?param1=%E2%98%A0',
     'URI for undef action with query params in unicode'
 );
+is(
+    Catalyst::uri_for( $context, 'quux', { 'param:1' => "foo" } )->as_string,
+    'http://127.0.0.1/foo/yada/quux?param%3A1=foo',
+    'URI for undef action with query params in unicode'
+);
 
 # test with object
 is(