Skip to content

Commit

Permalink
make sure broken Expires values are handled gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jun 1, 2013
1 parent 180cf67 commit 0bff603
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Mojo/Cookie/Response.pm
Expand Up @@ -33,7 +33,7 @@ sub parse {
my $next = shift @$tree;
my $rest = shift @$next;
push @$token, @$next;
$value .= ", $rest->[0]";
$value .= ", $rest->[0]" if $rest;
}

# This will only run once
Expand Down
10 changes: 10 additions & 0 deletions t/mojo/cookie.t
Expand Up @@ -361,6 +361,16 @@ is $cookies->[0]->to_string,
. ' path=/test; secure; Max-Age=60', 'right result';
is $cookies->[1], undef, 'no more cookies';

# Parse response cookie with broken Expires value
$cookies = Mojo::Cookie::Response->parse('foo=ba r; Expires=Th');
is $cookies->[0]->name, 'foo', 'right name';
is $cookies->[0]->value, 'ba r', 'right value';
is $cookies->[1], undef, 'no more cookies';
$cookies = Mojo::Cookie::Response->parse('foo=ba r; Expires=Th; Path=/test');
is $cookies->[0]->name, 'foo', 'right name';
is $cookies->[0]->value, 'ba r', 'right value';
is $cookies->[1], undef, 'no more cookies';

# Response cookie with Max-Age 0 and Expires 0
$cookie = Mojo::Cookie::Response->new;
$cookie->name('foo');
Expand Down

0 comments on commit 0bff603

Please sign in to comment.