Skip to content

Commit

Permalink
fixed cookie quoting bugs in Mojo::Cookie::Response
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jun 2, 2013
1 parent 3ced850 commit d7445d7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -2,6 +2,7 @@
4.11 2013-06-03
- Added allow and append methods to Mojo::Headers.
- Added split_header function to Mojo::Util.
- Fixed cookie quoting bugs in Mojo::Cookie::Response.
- Fixed a few small boundary and charset detection bugs in Mojo::Content.
- Fixed a few small filename detection bugs in Mojo::Message.
- Fixed small quality detection bug in Mojolicious::Types.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Cookie/Response.pm
Expand Up @@ -57,7 +57,7 @@ sub to_string {
# Name and value (Netscape)
return '' unless my $name = $self->name;
my $value = $self->value // '';
$value = $value =~ /[,;"]/ ? quote($value) : $value;
$value = $value =~ /[,;" ]/ ? quote($value) : $value;
my $cookie = "$name=$value";

# "expires" (Netscape)
Expand Down
4 changes: 2 additions & 2 deletions t/mojo/cookie.t
Expand Up @@ -137,7 +137,7 @@ $cookie = Mojo::Cookie::Response->new;
$cookie->name('foo');
$cookie->value('ba r');
$cookie->path('/test');
is $cookie->to_string, 'foo=ba r; path=/test', 'right format';
is $cookie->to_string, 'foo="ba r"; path=/test', 'right format';

# Response cookie without value as string
$cookie = Mojo::Cookie::Response->new;
Expand All @@ -161,7 +161,7 @@ $cookie->expires(1218092879);
$cookie->secure(1);
$cookie->httponly(1);
is $cookie->to_string,
'foo=ba r; expires=Thu, 07 Aug 2008 07:07:59 GMT; domain=example.com;'
'foo="ba r"; expires=Thu, 07 Aug 2008 07:07:59 GMT; domain=example.com;'
. ' path=/test; secure; Max-Age=60; HttpOnly', 'right format';

# Empty response cookie
Expand Down

0 comments on commit d7445d7

Please sign in to comment.