Skip to content

Commit

Permalink
the leading dot can be removed earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 10, 2015
1 parent 730b00b commit 8b5df65
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/Mojo/Cookie/Response.pm
Expand Up @@ -19,6 +19,7 @@ sub parse {

while (my ($name, $value) = splice @$pairs, 0, 2) {
next unless $ATTRS{my $attr = lc $name};
$value =~ s/^\.// if $attr eq 'domain';
$value = Mojo::Date->new($value)->epoch if $attr eq 'expires';
$value = 1 if $attr eq 'secure' || $attr eq 'httponly';
$cookies[-1]{$attr eq 'max-age' ? 'max_age' : $attr} = $value;
Expand Down
5 changes: 1 addition & 4 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -515,10 +515,7 @@ L<Mojo::UserAgent::CookieJar> object.
# Ignore cookies for public suffixes
my $ps = IO::Socket::SSL::PublicSuffix->default;
$ua->cookie_jar->ignore(sub {
my $cookie = shift;
return $ps->public_suffix($cookie->domain) eq $cookie->domain;
});
$ua->cookie_jar->ignore(sub { ($ps->public_suffix(shift->domain))[0] eq '' });
# Add custom cookie to the jar
$ua->cookie_jar->add(
Expand Down
1 change: 0 additions & 1 deletion lib/Mojo/UserAgent/CookieJar.pm
Expand Up @@ -49,7 +49,6 @@ sub collect {
# Validate domain
my $host = $url->ihost;
my $domain = lc($cookie->domain // $cookie->origin($host)->origin);
$domain =~ s/^\.//;
if (my $cb = $self->ignore) { next if $cb->($cookie) }
next if $host ne $domain && ($host !~ /\Q.$domain\E$/ || $host =~ /\.\d+$/);

Expand Down

0 comments on commit 8b5df65

Please sign in to comment.