Subject: | (patch) support spaces after semicolon, multiple equals un urlencode |
This patch fixes a couple of problems that happen if the content is
semi-malformed for the urlencoded parser.
If there is a space after the semicolon separator:
a=b; c=d
and if there is an equals sign in the value
a=b;c=d=f
It also adds three tests for these cases
Subject: | 01.HTTP-Body-0.9.tar.gz.cookiespaces.patch |
diff -Naur ../HTTP-Body-0.9.orig/lib/HTTP/Body/UrlEncoded.pm ../HTTP-Body-0.9/lib/HTTP/Body/UrlEncoded.pm
--- ../HTTP-Body-0.9.orig/lib/HTTP/Body/UrlEncoded.pm 2007-03-27 10:20:28.000000000 -0700
+++ ../HTTP-Body-0.9/lib/HTTP/Body/UrlEncoded.pm 2007-11-29 01:30:02.000000000 -0800
@@ -42,9 +42,9 @@
$self->{buffer} =~ tr/+/ /;
- 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;
diff -Naur ../HTTP-Body-0.9.orig/t/05urlencoded.t ../HTTP-Body-0.9/t/05urlencoded.t
--- ../HTTP-Body-0.9.orig/t/05urlencoded.t 2007-03-27 10:20:28.000000000 -0700
+++ ../HTTP-Body-0.9/t/05urlencoded.t 2007-11-29 01:08:54.000000000 -0800
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 10;
+use Test::More tests => 25;
use Cwd;
use HTTP::Body;
@@ -13,7 +13,7 @@
my $path = catdir( getcwd(), 't', 'data', 'urlencoded' );
-for ( my $i = 1; $i <= 2; $i++ ) {
+for ( my $i = 1; $i <= 5; $i++ ) {
my $test = sprintf( "%.3d", $i );
my $headers = YAML::LoadFile( catfile( $path, "$test-headers.yml" ) );
diff -Naur ../HTTP-Body-0.9.orig/t/data/urlencoded/003-content.dat ../HTTP-Body-0.9/t/data/urlencoded/003-content.dat
--- ../HTTP-Body-0.9.orig/t/data/urlencoded/003-content.dat 1969-12-31 16:00:00.000000000 -0800
+++ ../HTTP-Body-0.9/t/data/urlencoded/003-content.dat 2007-11-29 00:34:15.000000000 -0800
@@ -0,0 +1 @@
+one=foo; two=bar
diff -Naur ../HTTP-Body-0.9.orig/t/data/urlencoded/003-headers.yml ../HTTP-Body-0.9/t/data/urlencoded/003-headers.yml
--- ../HTTP-Body-0.9.orig/t/data/urlencoded/003-headers.yml 1969-12-31 16:00:00.000000000 -0800
+++ ../HTTP-Body-0.9/t/data/urlencoded/003-headers.yml 2007-11-29 00:44:48.000000000 -0800
@@ -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)'
diff -Naur ../HTTP-Body-0.9.orig/t/data/urlencoded/003-results.yml ../HTTP-Body-0.9/t/data/urlencoded/003-results.yml
--- ../HTTP-Body-0.9.orig/t/data/urlencoded/003-results.yml 1969-12-31 16:00:00.000000000 -0800
+++ ../HTTP-Body-0.9/t/data/urlencoded/003-results.yml 2007-11-29 00:32:41.000000000 -0800
@@ -0,0 +1,6 @@
+---
+body: ~
+param:
+ one: foo
+ two: bar
+upload: {}
diff -Naur ../HTTP-Body-0.9.orig/t/data/urlencoded/004-content.dat ../HTTP-Body-0.9/t/data/urlencoded/004-content.dat
--- ../HTTP-Body-0.9.orig/t/data/urlencoded/004-content.dat 1969-12-31 16:00:00.000000000 -0800
+++ ../HTTP-Body-0.9/t/data/urlencoded/004-content.dat 2007-11-29 00:44:33.000000000 -0800
@@ -0,0 +1 @@
+one=foo;two=bar
diff -Naur ../HTTP-Body-0.9.orig/t/data/urlencoded/004-headers.yml ../HTTP-Body-0.9/t/data/urlencoded/004-headers.yml
--- ../HTTP-Body-0.9.orig/t/data/urlencoded/004-headers.yml 1969-12-31 16:00:00.000000000 -0800
+++ ../HTTP-Body-0.9/t/data/urlencoded/004-headers.yml 2007-11-29 00:44:59.000000000 -0800
@@ -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)'
diff -Naur ../HTTP-Body-0.9.orig/t/data/urlencoded/004-results.yml ../HTTP-Body-0.9/t/data/urlencoded/004-results.yml
--- ../HTTP-Body-0.9.orig/t/data/urlencoded/004-results.yml 1969-12-31 16:00:00.000000000 -0800
+++ ../HTTP-Body-0.9/t/data/urlencoded/004-results.yml 2007-11-29 01:08:14.000000000 -0800
@@ -0,0 +1,6 @@
+---
+body: ~
+param:
+ one: foo
+ two: bar
+upload: {}
diff -Naur ../HTTP-Body-0.9.orig/t/data/urlencoded/005-content.dat ../HTTP-Body-0.9/t/data/urlencoded/005-content.dat
--- ../HTTP-Body-0.9.orig/t/data/urlencoded/005-content.dat 1969-12-31 16:00:00.000000000 -0800
+++ ../HTTP-Body-0.9/t/data/urlencoded/005-content.dat 2007-11-29 01:24:17.000000000 -0800
@@ -0,0 +1 @@
+one=foo;two=bar=bam
diff -Naur ../HTTP-Body-0.9.orig/t/data/urlencoded/005-headers.yml ../HTTP-Body-0.9/t/data/urlencoded/005-headers.yml
--- ../HTTP-Body-0.9.orig/t/data/urlencoded/005-headers.yml 1969-12-31 16:00:00.000000000 -0800
+++ ../HTTP-Body-0.9/t/data/urlencoded/005-headers.yml 2007-11-29 01:24:13.000000000 -0800
@@ -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)'
diff -Naur ../HTTP-Body-0.9.orig/t/data/urlencoded/005-results.yml ../HTTP-Body-0.9/t/data/urlencoded/005-results.yml
--- ../HTTP-Body-0.9.orig/t/data/urlencoded/005-results.yml 1969-12-31 16:00:00.000000000 -0800
+++ ../HTTP-Body-0.9/t/data/urlencoded/005-results.yml 2007-11-29 01:08:41.000000000 -0800
@@ -0,0 +1,6 @@
+---
+body: ~
+param:
+ one: foo
+ two: bar=bam
+upload: {}