Skip to content

Commit

Permalink
Merge pull request #292 from kraih/fix_cookie_jar
Browse files Browse the repository at this point in the history
Fix cookie jar
  • Loading branch information
kraih committed Feb 21, 2012
2 parents ef0378f + d412c69 commit 0fb9793
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -6,6 +6,7 @@ This file documents the revision history for Perl extension Mojolicious.
- Improved documentation.
- Fixed bug that prevented Mojo::IOLoop from dying when started
twice.
- Fixed a cookie jar path parsing bug. (marcus)

2.51 2012-02-19 00:00:00
- Added EXPERIMENTAL to_psgi method to Mojo::Server::PSGI.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/CookieJar.pm
Expand Up @@ -82,7 +82,7 @@ sub find {
Mojo::Cookie::Request->new(
name => $cookie->name,
value => $cookie->value
) if $path =~ /^$cpath/;
) if $path =~ /^\Q$cpath/;
}

$self->{jar}->{$domain} = \@new;
Expand Down
16 changes: 15 additions & 1 deletion t/mojo/cookiejar.t
@@ -1,6 +1,6 @@
use Mojo::Base -strict;

use Test::More tests => 83;
use Test::More tests => 84;

# "Hello, my name is Mr. Burns. I believe you have a letter for me.
# Okay Mr. Burns, what’s your first name.
Expand Down Expand Up @@ -307,3 +307,17 @@ is $cookies[0]->value, 'bar', 'right value';
is $cookies[0]->name, 'foo', 'right name';
is $cookies[0]->value, 'bar', 'right value';
is $cookies[1], undef, 'no second cookie';

# ( in path.
$jar = Mojo::CookieJar->new;
$jar->add(
Mojo::Cookie::Response->new(
domain => '.kraih.com',
path => '/foo(bar',
name => 'foo',
value => 'bar'
)
);
@cookies = $jar->find(Mojo::URL->new('http://kraih.com/foo%28bar'));
is $cookies[0]->name, 'foo', 'right name';

0 comments on commit 0fb9793

Please sign in to comment.