[Catalyst-commits] r7450 - in trunk/HTTP-Body: . lib/HTTP/Body t t/data/urlencoded

andyg at dev.catalyst.perl.org andyg at dev.catalyst.perl.org
Sat Feb 23 15:07:19 GMT 2008


Author: andyg
Date: 2008-02-23 15:07:19 +0000 (Sat, 23 Feb 2008)
New Revision: 7450

Added:
   trunk/HTTP-Body/t/data/urlencoded/004-content.dat
   trunk/HTTP-Body/t/data/urlencoded/004-headers.yml
   trunk/HTTP-Body/t/data/urlencoded/004-results.yml
   trunk/HTTP-Body/t/data/urlencoded/005-content.dat
   trunk/HTTP-Body/t/data/urlencoded/005-headers.yml
   trunk/HTTP-Body/t/data/urlencoded/005-results.yml
   trunk/HTTP-Body/t/data/urlencoded/006-content.dat
   trunk/HTTP-Body/t/data/urlencoded/006-headers.yml
   trunk/HTTP-Body/t/data/urlencoded/006-results.yml
Modified:
   trunk/HTTP-Body/Changes
   trunk/HTTP-Body/lib/HTTP/Body/UrlEncoded.pm
   trunk/HTTP-Body/t/05urlencoded.t
Log:
HTTP::Body, Patch from Tom Heady to fix urlencoded parser to handle spaces after semicolons and equal signs in the value

Modified: trunk/HTTP-Body/Changes
===================================================================
--- trunk/HTTP-Body/Changes	2008-02-23 14:53:13 UTC (rev 7449)
+++ trunk/HTTP-Body/Changes	2008-02-23 15:07:19 UTC (rev 7450)
@@ -2,6 +2,8 @@
 
 1.00
         - Added support for chunked requests if no $length value is passed to new().
+        - Fixed urlencoded parser to handle spaces after semicolons and equal signs
+          in the value. (Tom Heady, http://rt.cpan.org/Ticket/Display.html?id=31055)
 
 0.9   2007-03-27 14:00:00
         - Fixed bug where empty fields in multipart/form-data were ignored.

Modified: trunk/HTTP-Body/lib/HTTP/Body/UrlEncoded.pm
===================================================================
--- trunk/HTTP-Body/lib/HTTP/Body/UrlEncoded.pm	2008-02-23 14:53:13 UTC (rev 7449)
+++ trunk/HTTP-Body/lib/HTTP/Body/UrlEncoded.pm	2008-02-23 15:07:19 UTC (rev 7450)
@@ -45,9 +45,9 @@
     # Note: s/// appears faster than tr///
     $self->{buffer} =~ s/\+/ /g;
 
-    for my $pair ( split( /[&;]/, $self->{buffer} ) ) {
+    for my $pair ( split( /&|;(?:\s+)?/, $self->{buffer} ) ) {
 
-        my ( $name, $value ) = split( /=/, $pair );
+        my ( $name, $value ) = split( /=/, $pair , 2 );
 
         next unless defined $name;
         next unless defined $value;

Modified: trunk/HTTP-Body/t/05urlencoded.t
===================================================================
--- trunk/HTTP-Body/t/05urlencoded.t	2008-02-23 14:53:13 UTC (rev 7449)
+++ trunk/HTTP-Body/t/05urlencoded.t	2008-02-23 15:07:19 UTC (rev 7450)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 16;
+use Test::More tests => 31;
 
 use Cwd;
 use Digest::MD5 qw(md5_hex);
@@ -14,7 +14,7 @@
 
 my $path = catdir( getcwd(), 't', 'data', 'urlencoded' );
 
-for ( my $i = 1; $i <= 3; $i++ ) {
+for ( my $i = 1; $i <= 6; $i++ ) {
 
     my $test    = sprintf( "%.3d", $i );
     my $headers = YAML::LoadFile( catfile( $path, "$test-headers.yml" ) );

Added: trunk/HTTP-Body/t/data/urlencoded/004-content.dat
===================================================================
--- trunk/HTTP-Body/t/data/urlencoded/004-content.dat	                        (rev 0)
+++ trunk/HTTP-Body/t/data/urlencoded/004-content.dat	2008-02-23 15:07:19 UTC (rev 7450)
@@ -0,0 +1 @@
+one=foo; two=bar


Property changes on: trunk/HTTP-Body/t/data/urlencoded/004-content.dat
___________________________________________________________________
Name: svn:keywords
   + Id

Added: trunk/HTTP-Body/t/data/urlencoded/004-headers.yml
===================================================================
--- trunk/HTTP-Body/t/data/urlencoded/004-headers.yml	                        (rev 0)
+++ trunk/HTTP-Body/t/data/urlencoded/004-headers.yml	2008-02-23 15:07:19 UTC (rev 7450)
@@ -0,0 +1,4 @@
+---
+Content-Length: 16
+Content-Type: application/x-www-form-urlencoded
+User-Agent: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)'


Property changes on: trunk/HTTP-Body/t/data/urlencoded/004-headers.yml
___________________________________________________________________
Name: svn:keywords
   + Id

Added: trunk/HTTP-Body/t/data/urlencoded/004-results.yml
===================================================================
--- trunk/HTTP-Body/t/data/urlencoded/004-results.yml	                        (rev 0)
+++ trunk/HTTP-Body/t/data/urlencoded/004-results.yml	2008-02-23 15:07:19 UTC (rev 7450)
@@ -0,0 +1,6 @@
+---
+body: ~
+param:
+  one: foo
+  two: bar
+upload: {}


Property changes on: trunk/HTTP-Body/t/data/urlencoded/004-results.yml
___________________________________________________________________
Name: svn:keywords
   + Id

Added: trunk/HTTP-Body/t/data/urlencoded/005-content.dat
===================================================================
--- trunk/HTTP-Body/t/data/urlencoded/005-content.dat	                        (rev 0)
+++ trunk/HTTP-Body/t/data/urlencoded/005-content.dat	2008-02-23 15:07:19 UTC (rev 7450)
@@ -0,0 +1 @@
+one=foo;two=bar


Property changes on: trunk/HTTP-Body/t/data/urlencoded/005-content.dat
___________________________________________________________________
Name: svn:keywords
   + Id

Added: trunk/HTTP-Body/t/data/urlencoded/005-headers.yml
===================================================================
--- trunk/HTTP-Body/t/data/urlencoded/005-headers.yml	                        (rev 0)
+++ trunk/HTTP-Body/t/data/urlencoded/005-headers.yml	2008-02-23 15:07:19 UTC (rev 7450)
@@ -0,0 +1,4 @@
+---
+Content-Length: 15
+Content-Type: application/x-www-form-urlencoded
+User-Agent: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)'


Property changes on: trunk/HTTP-Body/t/data/urlencoded/005-headers.yml
___________________________________________________________________
Name: svn:keywords
   + Id

Added: trunk/HTTP-Body/t/data/urlencoded/005-results.yml
===================================================================
--- trunk/HTTP-Body/t/data/urlencoded/005-results.yml	                        (rev 0)
+++ trunk/HTTP-Body/t/data/urlencoded/005-results.yml	2008-02-23 15:07:19 UTC (rev 7450)
@@ -0,0 +1,6 @@
+---
+body: ~
+param:
+  one: foo
+  two: bar
+upload: {}


Property changes on: trunk/HTTP-Body/t/data/urlencoded/005-results.yml
___________________________________________________________________
Name: svn:keywords
   + Id

Added: trunk/HTTP-Body/t/data/urlencoded/006-content.dat
===================================================================
--- trunk/HTTP-Body/t/data/urlencoded/006-content.dat	                        (rev 0)
+++ trunk/HTTP-Body/t/data/urlencoded/006-content.dat	2008-02-23 15:07:19 UTC (rev 7450)
@@ -0,0 +1 @@
+one=foo;two=bar=bam


Property changes on: trunk/HTTP-Body/t/data/urlencoded/006-content.dat
___________________________________________________________________
Name: svn:keywords
   + Id

Added: trunk/HTTP-Body/t/data/urlencoded/006-headers.yml
===================================================================
--- trunk/HTTP-Body/t/data/urlencoded/006-headers.yml	                        (rev 0)
+++ trunk/HTTP-Body/t/data/urlencoded/006-headers.yml	2008-02-23 15:07:19 UTC (rev 7450)
@@ -0,0 +1,4 @@
+---
+Content-Length: 19
+Content-Type: application/x-www-form-urlencoded
+User-Agent: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)'


Property changes on: trunk/HTTP-Body/t/data/urlencoded/006-headers.yml
___________________________________________________________________
Name: svn:keywords
   + Id

Added: trunk/HTTP-Body/t/data/urlencoded/006-results.yml
===================================================================
--- trunk/HTTP-Body/t/data/urlencoded/006-results.yml	                        (rev 0)
+++ trunk/HTTP-Body/t/data/urlencoded/006-results.yml	2008-02-23 15:07:19 UTC (rev 7450)
@@ -0,0 +1,6 @@
+---
+body: ~
+param:
+  one: foo
+  two: bar=bam
+upload: {}


Property changes on: trunk/HTTP-Body/t/data/urlencoded/006-results.yml
___________________________________________________________________
Name: svn:keywords
   + Id




More information about the Catalyst-commits mailing list