[Catalyst-commits] r10047 - in trunk/HTTP-Body: . lib/HTTP lib/HTTP/Body t t/data/multipart

andyg at dev.catalyst.perl.org andyg at dev.catalyst.perl.org
Thu May 7 15:41:40 GMT 2009


Author: andyg
Date: 2009-05-07 15:41:40 +0000 (Thu, 07 May 2009)
New Revision: 10047

Added:
   trunk/HTTP-Body/t/data/multipart/013-content.dat
   trunk/HTTP-Body/t/data/multipart/013-headers.yml
   trunk/HTTP-Body/t/data/multipart/013-results.yml
Modified:
   trunk/HTTP-Body/Changes
   trunk/HTTP-Body/lib/HTTP/Body.pm
   trunk/HTTP-Body/lib/HTTP/Body/MultiPart.pm
   trunk/HTTP-Body/t/04multipart.t
Log:
Fix multipart boundaries with commas

Modified: trunk/HTTP-Body/Changes
===================================================================
--- trunk/HTTP-Body/Changes	2009-05-07 15:14:16 UTC (rev 10046)
+++ trunk/HTTP-Body/Changes	2009-05-07 15:41:40 UTC (rev 10047)
@@ -1,5 +1,9 @@
 This file documents the revision history for Perl extension HTTP::Body.
 
+1.06    
+        - Fixed parsing of multipart bodies with boundaries that contain commas.
+          (Tomas Doran, http://rt.cpan.org/Public/Bug/Display.html?id=41407)
+
 1.05    2008-12-01 17:15:00
         - Removed useless eval + require in new().
 

Modified: trunk/HTTP-Body/lib/HTTP/Body/MultiPart.pm
===================================================================
--- trunk/HTTP-Body/lib/HTTP/Body/MultiPart.pm	2009-05-07 15:14:16 UTC (rev 10046)
+++ trunk/HTTP-Body/lib/HTTP/Body/MultiPart.pm	2009-05-07 15:41:40 UTC (rev 10047)
@@ -30,7 +30,7 @@
 sub init {
     my $self = shift;
 
-    unless ( $self->content_type =~ /boundary=\"?([^\";,]+)\"?/ ) {
+    unless ( $self->content_type =~ /boundary=\"?([^\";]+)\"?/ ) {
         my $content_type = $self->content_type;
         Carp::croak("Invalid boundary in content_type: '$content_type'");
     }

Modified: trunk/HTTP-Body/lib/HTTP/Body.pm
===================================================================
--- trunk/HTTP-Body/lib/HTTP/Body.pm	2009-05-07 15:14:16 UTC (rev 10046)
+++ trunk/HTTP-Body/lib/HTTP/Body.pm	2009-05-07 15:41:40 UTC (rev 10047)
@@ -4,7 +4,7 @@
 
 use Carp       qw[ ];
 
-our $VERSION = '1.05';
+our $VERSION = '1.06';
 
 our $TYPES = {
     'application/octet-stream'          => 'HTTP::Body::OctetStream',

Modified: trunk/HTTP-Body/t/04multipart.t
===================================================================
--- trunk/HTTP-Body/t/04multipart.t	2009-05-07 15:14:16 UTC (rev 10046)
+++ trunk/HTTP-Body/t/04multipart.t	2009-05-07 15:41:40 UTC (rev 10047)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 98;
+use Test::More tests => 102;
 
 use Cwd;
 use HTTP::Body;
@@ -14,7 +14,7 @@
 
 my $path = catdir( getcwd(), 't', 'data', 'multipart' );
 
-for ( my $i = 1; $i <= 12; $i++ ) {
+for ( my $i = 1; $i <= 13; $i++ ) {
 
     my $test    = sprintf( "%.3d", $i );
     my $headers = YAML::LoadFile( catfile( $path, "$test-headers.yml" ) );
@@ -47,7 +47,8 @@
 
     is_deeply( $body->body, $results->{body}, "$test MultiPart body" );
     is_deeply( $body->param, $results->{param}, "$test MultiPart param" );
-    is_deeply( $body->upload, $results->{upload}, "$test MultiPart upload" );
+    is_deeply( $body->upload, $results->{upload}, "$test MultiPart upload" )
+        if $results->{upload};
     cmp_ok( $body->state, 'eq', 'done', "$test MultiPart state" );
     cmp_ok( $body->length, '==', $body->content_length, "$test MultiPart length" );
     

Added: trunk/HTTP-Body/t/data/multipart/013-content.dat
===================================================================
--- trunk/HTTP-Body/t/data/multipart/013-content.dat	                        (rev 0)
+++ trunk/HTTP-Body/t/data/multipart/013-content.dat	2009-05-07 15:41:40 UTC (rev 10047)
@@ -0,0 +1,23 @@
+------------0x'K()h+T_m,L-b.O/u:N=d?ArY
+Content-Disposition: form-data; name="text1"
+
+Ratione accusamus aspernatur aliquam
+------------0x'K()h+T_m,L-b.O/u:N=d?ArY
+Content-Disposition: form-data; name="text2"
+
+
+------------0x'K()h+T_m,L-b.O/u:N=d?ArY
+Content-Disposition: form-data; name="select"
+
+A
+------------0x'K()h+T_m,L-b.O/u:N=d?ArY
+Content-Disposition: form-data; name="select"
+
+B
+------------0x'K()h+T_m,L-b.O/u:N=d?ArY
+Content-Disposition: form-data; name="textarea"
+
+Voluptatem cumque voluptate sit recusandae at. Et quas facere rerum unde esse. Sit est et voluptatem. Vel temporibus velit neque odio non.
+
+Molestias rerum ut sapiente facere repellendus illo. Eum nulla quis aut. Quidem voluptas vitae ipsam officia voluptatibus eveniet. Aspernatur cupiditate ratione aliquam quidem corrupti. Eos sunt rerum non optio culpa.
+------------0x'K()h+T_m,L-b.O/u:N=d?ArY--


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

Added: trunk/HTTP-Body/t/data/multipart/013-headers.yml
===================================================================
--- trunk/HTTP-Body/t/data/multipart/013-headers.yml	                        (rev 0)
+++ trunk/HTTP-Body/t/data/multipart/013-headers.yml	2009-05-07 15:41:40 UTC (rev 10047)
@@ -0,0 +1,4 @@
+---
+Content-Length: 900
+Content-Type: multipart/form-data; boundary=----------0x'K()h+T_m,L-b.O/u:N=d?ArY
+User-Agent: 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/312.1 (KHTML, like Gecko) Safari/312'


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

Added: trunk/HTTP-Body/t/data/multipart/013-results.yml
===================================================================
--- trunk/HTTP-Body/t/data/multipart/013-results.yml	                        (rev 0)
+++ trunk/HTTP-Body/t/data/multipart/013-results.yml	2009-05-07 15:41:40 UTC (rev 10047)
@@ -0,0 +1,9 @@
+---
+body: ~
+param:
+  select:
+    - A
+    - B
+  text1: Ratione accusamus aspernatur aliquam
+  text2: ""
+  textarea: "Voluptatem cumque voluptate sit recusandae at. Et quas facere rerum unde esse. Sit est et voluptatem. Vel temporibus velit neque odio non.\r\n\r\nMolestias rerum ut sapiente facere repellendus illo. Eum nulla quis aut. Quidem voluptas vitae ipsam officia voluptatibus eveniet. Aspernatur cupiditate ratione aliquam quidem corrupti. Eos sunt rerum non optio culpa."


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




More information about the Catalyst-commits mailing list