Sat Dec 6 17:28:09 EST 2008 Mark Stosberg <mark@summersault.com>
* Support cookies in which one of multiple values is empty. Ported from CGI.pm
Sat Dec 6 17:19:14 EST 2008 Mark Stosberg <mark@summersault.com>
* Support cookies which have an equals sign in the value. Ported from CGI.pm
Sat Dec 6 16:52:03 EST 2008 Mark Stosberg <mark@summersault.com>
* - Accept a comma as well as semi-colon as a cookie separator. This is consistent with CGI.pm
as well as RFC 2965, which states: "A server SHOULD also accept comma (,)
as the separator between cookie-values for future compatibility."
Sat Dec 6 16:38:08 EST 2008 Mark Stosberg <mark@summersault.com>
* - CGI::Simple::Cookie, fixed bug when cookie had both leading and trailing white space
diff -rN -u old-CGI-Simple-1.106/Changes new-CGI-Simple-1.106/Changes
--- old-CGI-Simple-1.106/Changes 2008-12-06 18:05:52.000000000 -0500
+++ new-CGI-Simple-1.106/Changes 2008-12-06 18:05:52.000000000 -0500
@@ -139,4 +139,12 @@
1.107 2008-12-06
- Fixed bug when calling unescapeHTML on HTML that wasn't properly escaped in the first place.
Thanks to M-Uchino and Mark Stosberg.
+ - CGI::Simple::Cookie, fixed bug when cookie had both leading and trailing white space
+ (RT#34314, Ron Savage and Mark Stosberg)
+ - Accept a comma as well as semi-colon as a cookie separator. This is consistent with CGI.pm
+ as well as RFC 2965, which states: "A server SHOULD also accept comma (,)
+ as the separator between cookie-values for future compatibility." (Mark Stosberg)
+ - Support cookies which have an equals sign in the value. Ported from CGI.pm (Mark Stosberg)
+ - Support cookies in which one of multiple values is empty. Ported from CGI.pm (Mark Stosberg)
+
diff -rN -u old-CGI-Simple-1.106/lib/CGI/Simple/Cookie.pm new-CGI-Simple-1.106/lib/CGI/Simple/Cookie.pm
--- old-CGI-Simple-1.106/lib/CGI/Simple/Cookie.pm 2008-12-06 18:05:52.000000000 -0500
+++ new-CGI-Simple-1.106/lib/CGI/Simple/Cookie.pm 2008-12-06 18:05:52.000000000 -0500
@@ -29,13 +29,17 @@
my ( $self, $raw_cookie ) = @_;
return () unless $raw_cookie;
my %results;
- my @pairs = split "; ?", $raw_cookie;
+ my @pairs = split "[;,] ?", $raw_cookie;
for my $pair ( @pairs ) {
- $pair =~ s/^\s+|\s+$//; # trim leading trailing whitespace
- my ( $key, $value ) = split "=", $pair;
- next unless defined $value;
- my @values = map { unescape( $_ ) } split /[&;]/, $value;
- $key = unescape( $key );
+ $pair =~ s/^\s+|\s+$//g; # trim leading trailing whitespace
+ my($key,$value) = split("=",$pair,2);
+ next if !defined($value);
+ my @values = ();
+ if ($value ne '') {
+ @values = map unescape($_),split(/[&;]/,$value.'&dmy');
+ pop @values;
+ }
+ $key = unescape($key);
# A bug in Netscape can cause several cookies with same name to
# appear. The FIRST one in HTTP_COOKIE is the most recent version.
diff -rN -u old-CGI-Simple-1.106/t/020.cookie.t new-CGI-Simple-1.106/t/020.cookie.t
--- old-CGI-Simple-1.106/t/020.cookie.t 2008-12-06 18:05:52.000000000 -0500
+++ new-CGI-Simple-1.106/t/020.cookie.t 2008-12-06 18:05:52.000000000 -0500
@@ -17,7 +17,7 @@
}
my @test_cookie = (
- 'foo=123; bar=qwerty; baz=wibble; qux=a1',
+ 'foo=123, bar=qwerty; baz=wib=ble ; qux=1&2&',
'foo=123; bar=qwerty; baz=wibble;',
'foo=vixen; bar=cow; baz=bitch; qux=politician',
'foo=a%20phrase; bar=yes%2C%20a%20phrase; baz=%5Ewibble; qux=%27',
@@ -44,8 +44,9 @@
is( $result{foo}->value, '123', "cookie foo is correct" );
is( $result{bar}->value, 'qwerty', "cookie bar is correct" );
- is( $result{baz}->value, 'wibble', "cookie baz is correct" );
- is( $result{qux}->value, 'a1', "cookie qux is correct" );
+ is( $result{baz}->value, 'wib=ble', "cookie baz is correct" );
+ my @values = $result{qux}->value;
+ is_deeply ( \@values, [1,2,''], "multiple values are supported including empty values." );
}
#-----------------------------------------------------------------------------