Skip to content

Commit afe187d

Browse files
committed
Don't let version=1 override behaviour if specified with a plan Set-Cookie header.
1 parent 74c3257 commit afe187d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/HTTP/Cookies.pm

+3
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ sub extract_cookies
237237
$expires++;
238238
}
239239
}
240+
elsif (!$first_param && lc($k) =~ /^(?:version|discard|ns-cookie)/) {
241+
# ignore
242+
}
240243
else {
241244
push(@cur, $k => $v);
242245
}

t/base/cookies.t

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
print "1..44\n";
1+
print "1..45\n";
22

33
#use LWP::Debug '+';
44
use HTTP::Cookies;
@@ -678,6 +678,17 @@ print "not " unless $c->as_string eq <<'EOT'; print "ok 44\n";
678678
Set-Cookie3: CUSTOMER=WILE_E_COYOTE; path="/"; domain=example.com; path_spec; discard; version=0
679679
EOT
680680
681+
# Test Set-Cookie with version set
682+
$c = HTTP::Cookies->new;
683+
$res->header("Set-Cookie" => "foo=\"bar\";version=1");
684+
#print $res->as_string;
685+
$c->extract_cookies($res);
686+
#print $c->as_string;
687+
$req = HTTP::Request->new(GET => "http://www.example.com/foo");
688+
$c->add_cookie_header($req);
689+
#print $req->as_string;
690+
print "not " unless $req->header("Cookie") eq "foo=\"bar\"";
691+
print "ok 45\n";
681692
682693
#-------------------------------------------------------------------
683694

0 commit comments

Comments
 (0)