Skip to content

Commit

Permalink
expires is a valid cookie name
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 11, 2015
1 parent 45226f6 commit 5547dff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Mojo/Util.pm
Expand Up @@ -388,7 +388,7 @@ sub _header {
my (@tree, @token);
while ($str =~ s/^[,;\s]*([^=;, ]+)\s*//) {
push @token, $1, undef;
my $expires = $cookie && lc $1 eq 'expires';
my $expires = $cookie && @token > 2 && lc $1 eq 'expires';

# Special "expires" value
if ($expires && $str =~ s/^=\s*$EXPIRES_RE//o) { $token[-1] = $1 }
Expand Down
7 changes: 7 additions & 0 deletions t/mojo/util.t
Expand Up @@ -106,6 +106,13 @@ is_deeply split_cookie_header(
'a=b; expires=Sunday 06 Nov 94 08:49:37UTC; path=/'),
[['a', 'b', 'expires', 'Sunday 06 Nov 94 08:49:37UTC', 'path', '/']],
'right result';
$header = 'expires=Thu, 07 Aug 2008 07:07:59 GMT, a=b';
$tree = [
['expires', 'Thu'],
['07', undef, 'Aug', undef, '2008', undef, '07:07:59', undef, 'GMT', undef],
['a', 'b']
];
is_deeply split_cookie_header($header), $tree, 'right result';

# unindent
is unindent(" test\n 123\n 456\n"), "test\n 123\n456\n",
Expand Down

0 comments on commit 5547dff

Please sign in to comment.