Cookies with empty values #198

Closed
skaurus opened this Issue Aug 15, 2011 · 2 comments

Projects

None yet

2 participants

@skaurus

If I set cookie with empty value, headers will look like this:

Set-Cookie: cookiename; Version=1; Domain=example.com; Path=/; expires=Mon, 15 Aug 2011 17:14:39 GMT

This is not parsed by FF5, at least when there a other cookies. For example, Mojo can response with these headers:

Status=Found - 302
Server=nginx/1.0.4
Connection=keep-alive
X-Powered-By=Mojolicious (Perl)
Location=http://example.com/
Set-Cookie=user_info=0; Version=1; Domain=example.com; Path=/; expires=Thu, 23 Apr 2043 22:45:07 GMT
mrc; Version=1; Domain=example.com; Path=/; expires=Mon, 15 Aug 2011 20:57:27 GMT
knot=eyJ2YWxpZF90byI6MCwibmFtZSI6IndyQjJBS201Nmw1TSIsInRlbXBfbmFtZSI6MSwiZXhwaXJlcyI6MTM0NDk3NzkwN30---504861f8bc8377f06d88fdf24babd9fe; Version=1; Domain=.example.com; Path=/; expires=Tue, 14 Aug 2012 20:58:27 GMT
Date=Mon, 15 Aug 2011 20:58:27 GMT
Content-Length=0

(tracked by Tamper Data), and cookies will be parsed this way: http://clip2net.com/clip/m7102/1313442123-clip-2kb.png (as shown by Tamper Data too, also I set "ask me about every cookie" and I seen only user_info and knot cookies).

Changing Mojo::Cookie::Response.pm line from

$cookie .= "=$value" if defined $value && length $value;

to

$cookie .= "=$value" if defined $value;

resolves this issue.

This looks like according with W3C spec, not sure about Netscape one.

@kraih
Owner

Thanks, fixed. cc45268

@kraih kraih closed this Aug 15, 2011
@skaurus

Fantastic! Thanks a lot :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment