Skip to content

Commit

Permalink
be a little more liberal with expires values
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 11, 2015
1 parent 83f55e0 commit 0ea6b5d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/Mojo/Cookie/Response.pm
Expand Up @@ -40,7 +40,7 @@ sub to_string {

# "expires"
my $expires = $self->expires;
if (defined $expires) { $cookie .= '; expires=' . Mojo::Date->new($expires) }
$cookie .= '; expires=' . Mojo::Date->new($expires) if defined $expires;

# "domain"
if (my $domain = $self->domain) { $cookie .= "; domain=$domain" }
Expand All @@ -51,12 +51,12 @@ sub to_string {
# "secure"
$cookie .= "; secure" if $self->secure;

# "Max-Age"
if (defined(my $max = $self->max_age)) { $cookie .= "; Max-Age=$max" }

# "HttpOnly"
$cookie .= "; HttpOnly" if $self->httponly;

# "Max-Age"
if (defined(my $max = $self->max_age)) { $cookie .= "; Max-Age=$max" }

return $cookie;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Date.pm
Expand Up @@ -28,7 +28,7 @@ sub parse {
# RFC 850/1036 (Sunday, 06-Nov-94 08:49:37 GMT)
my $offset = 0;
my ($day, $month, $year, $h, $m, $s);
if ($date =~ /^\w+\,\s+(\d+)\W+(\w+)\D+(\d+)\s+(\d+):(\d+):(\d+)\s+GMT$/) {
if ($date =~ /^\w+\,\s+(\d+)\W+(\w+)\D+(\d+)\s+(\d+):(\d+):(\d+)\s+\w+$/) {
($day, $month, $year, $h, $m, $s) = ($1, $MONTHS{$2}, $3, $4, $5, $6);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Util.pm
Expand Up @@ -49,7 +49,7 @@ my %XML = (
);

# "Sun, 06 Nov 1994 08:49:37 GMT" and "Sunday, 06-Nov-94 08:49:37 GMT"
my $EXPIRES_RE = qr/(\w+\,\s+\d+\W+\w+\D+\d+\s+\d+:\d+:\d+\s+GMT)/;
my $EXPIRES_RE = qr/(\w+\,\s+\d+\W+\w+\D+\d+\s+\d+:\d+:\d+\s+\w+)/;

# Encoding cache
my %CACHE;
Expand Down
2 changes: 1 addition & 1 deletion t/mojo/cookie.t
Expand Up @@ -166,7 +166,7 @@ $cookie->secure(1);
$cookie->httponly(1);
is $cookie->to_string,
'0="ba r"; expires=Thu, 07 Aug 2008 07:07:59 GMT; domain=example.com;'
. ' path=/test; secure; Max-Age=60; HttpOnly', 'right format';
. ' path=/test; secure; HttpOnly; Max-Age=60', 'right format';

# Empty response cookie
is_deeply(Mojo::Cookie::Response->parse, [], 'no cookies');
Expand Down

0 comments on commit 0ea6b5d

Please sign in to comment.