Permalink
Browse files

fixed small cookie formatting bug

  • Loading branch information...
1 parent 77f1557 commit 73d6ce2a90840beb3ae7184c5470265ffb09858c @kraih committed May 8, 2012
Showing with 19 additions and 18 deletions.
  1. +1 −0 Changes
  2. +2 −2 lib/Mojo/Cookie.pm
  3. +2 −2 lib/Mojo/Cookie/Response.pm
  4. +14 −14 t/mojo/cookie.t
View
@@ -8,6 +8,7 @@ This file documents the revision history for Perl extension Mojolicious.
instead of errors.
- Improved documentation.
- Fixed typo in 414 status message.
+ - Fixed small cookie formatting bug.
- Fixed small backlog bug in Mojo::Server::Daemon.
2.93 2012-05-05
View
@@ -27,8 +27,8 @@ sub _tokenize {
last unless $string =~ s/^\s*([^=;,]+)\s*=?\s*//;
my $name = $1;
- # "expires" is a special case, thank you Netscape...
- $string =~ s/^([^;,]+,?[^;,]+)/"$1"/ if $name =~ /^expires$/i;
+ # "Expires" is a special case, thank you Netscape...
+ $string =~ s/^([^;,]+,?[^;,]+)/"$1"/ if $name =~ /^Expires$/i;
# Value
my $value;
@@ -6,7 +6,7 @@ use Mojo::Util 'quote';
has [qw/domain httponly max_age path secure/];
-my $ATTR_RE = qr/(Domain|expires|HttpOnly|Max-Age|Path|Secure)/msi;
+my $ATTR_RE = qr/(Domain|Expires|HttpOnly|Max-Age|Path|Secure)/msi;
sub expires {
my $self = shift;
@@ -73,7 +73,7 @@ sub to_string {
if (defined(my $m = $self->max_age)) { $cookie .= "; Max-Age=$m" }
# Expires
- if (defined(my $e = $self->expires)) { $cookie .= "; expires=$e" }
+ if (defined(my $e = $self->expires)) { $cookie .= "; Expires=$e" }
# Secure
if (my $secure = $self->secure) { $cookie .= "; Secure" }
View
@@ -170,13 +170,13 @@ $cookie->expires(1218092879);
$cookie->secure(1);
$cookie->httponly(1);
is $cookie->to_string, 'foo=ba r; Domain=kraih.com; Path=/test; Max-Age=60;'
- . ' expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure; HttpOnly', 'right format';
+ . ' Expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure; HttpOnly', 'right format';
# Parse response cookie (RFC 6265)
$cookies
= Mojo::Cookie::Response->parse(
'foo=ba r; Domain=kraih.com; Path=/test; Max-Age=60;'
- . ' expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure;');
+ . ' Expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure;');
is $cookies->[0]->name, 'foo', 'right name';
is $cookies->[0]->value, 'ba r', 'right value';
is $cookies->[0]->domain, 'kraih.com', 'right domain';
@@ -191,7 +191,7 @@ is $cookies->[1], undef, 'no more cookies';
$cookies
= Mojo::Cookie::Response->parse(
'foo="b a\" r\"\\\\"; Domain=kraih.com; Path=/test; Max-Age=60;'
- . ' expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure');
+ . ' Expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure');
is $cookies->[0]->name, 'foo', 'right name';
is $cookies->[0]->value, 'b a" r"\\', 'right value';
is $cookies->[0]->domain, 'kraih.com', 'right domain';
@@ -206,7 +206,7 @@ is $cookies->[1], undef, 'no more cookies';
$cookies
= Mojo::Cookie::Response->parse(
'foo="b a\" ;r\"\\\\"; Domain=kraih.com; Path=/test; Max-Age=60;'
- . ' expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure');
+ . ' Expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure');
is $cookies->[0]->name, 'foo', 'right name';
is $cookies->[0]->value, 'b a" ;r"\\', 'right value';
is $cookies->[0]->domain, 'kraih.com', 'right domain';
@@ -221,7 +221,7 @@ is $cookies->[1], undef, 'no more cookies';
$cookies
= Mojo::Cookie::Response->parse(
'foo="b ,a\";= r\"\\\\"; Domain=kraih.com; Path=/test; Max-Age=60;'
- . ' expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure');
+ . ' Expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure');
is $cookies->[0]->name, 'foo', 'right name';
is $cookies->[0]->value, 'b ,a";= r"\\', 'right value';
is $cookies->[0]->domain, 'kraih.com', 'right domain';
@@ -246,7 +246,7 @@ is $cookies->[1], undef, 'no more cookies';
$cookies
= Mojo::Cookie::Response->parse(
'foo="b ,a\" r\"\\\\"; Domain=kraih.com; Path=/test; Max-Age=60;'
- . ' expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure');
+ . ' Expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure');
is $cookies->[0]->name, 'foo', 'right name';
is $cookies->[0]->value, 'b ,a" r"\\', 'right value';
is $cookies->[0]->domain, 'kraih.com', 'right domain';
@@ -271,7 +271,7 @@ is $cookies->[1], undef, 'no more cookies';
$cookies
= Mojo::Cookie::Response->parse(
'foo="b ;a\" r\"\\\\"; Domain=kraih.com; Path=/test; Max-Age=60;'
- . ' expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure');
+ . ' Expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure');
is $cookies->[0]->name, 'foo', 'right name';
is $cookies->[0]->value, 'b ;a" r"\\', 'right value';
is $cookies->[0]->domain, 'kraih.com', 'right domain';
@@ -296,7 +296,7 @@ is $cookies->[1], undef, 'no more cookies';
$cookies
= Mojo::Cookie::Response->parse(
'foo="\"b a\" r\""; Domain=kraih.com; Path=/test; Max-Age=60;'
- . ' expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure');
+ . ' Expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure');
is $cookies->[0]->name, 'foo', 'right name';
is $cookies->[0]->value, '"b a" r"', 'right value';
is $cookies->[0]->domain, 'kraih.com', 'right domain';
@@ -331,7 +331,7 @@ is $cookies->[0]->expires, 'Thu, 07 Aug 2008 07:07:59 GMT',
'right expires value';
is $cookies->[0]->secure, '1', 'right secure flag';
is $cookies->[0]->to_string, 'foo=; Domain=kraih.com; Path=/test; Max-Age=60;'
- . ' expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure', 'right result';
+ . ' Expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure', 'right result';
is $cookies->[1], undef, 'no more cookies';
$cookies
= Mojo::Cookie::Response->parse(
@@ -346,25 +346,25 @@ is $cookies->[0]->expires, 'Thu, 07 Aug 2008 07:07:59 GMT',
'right expires value';
is $cookies->[0]->secure, '1', 'right secure flag';
is $cookies->[0]->to_string, 'foo=; Domain=kraih.com; Path=/test; Max-Age=60;'
- . ' expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure', 'right result';
+ . ' Expires=Thu, 07 Aug 2008 07:07:59 GMT; Secure', 'right result';
is $cookies->[1], undef, 'no more cookies';
-# Response cookie with Max-Age 0 and expires 0
+# Response cookie with Max-Age 0 and Expires 0
$cookie = Mojo::Cookie::Response->new;
$cookie->name('foo');
$cookie->value('bar');
$cookie->path('/');
$cookie->max_age(0);
$cookie->expires(0);
is $cookie->to_string,
- 'foo=bar; Path=/; Max-Age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT',
+ 'foo=bar; Path=/; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT',
'right format';
-# Parse response cookie with Max-Age 0 and expires 0 (RFC 6265)
+# Parse response cookie with Max-Age 0 and Expires 0 (RFC 6265)
$cookies
= Mojo::Cookie::Response->parse(
'foo=bar; Domain=kraih.com; Path=/; Max-Age=0;'
- . ' expires=Thu, 01 Jan 1970 00:00:00 GMT; Secure');
+ . ' Expires=Thu, 01 Jan 1970 00:00:00 GMT; Secure');
is $cookies->[0]->name, 'foo', 'right name';
is $cookies->[0]->value, 'bar', 'right value';
is $cookies->[0]->domain, 'kraih.com', 'right domain';

0 comments on commit 73d6ce2

Please sign in to comment.