Skip to content

Commit

Permalink
Merge pull request WordPress#370 from aaronjorbin/fix/null-cookie-value
Browse files Browse the repository at this point in the history
handle no domain in a PHP7.4 compatable way
  • Loading branch information
jrfnl committed Oct 5, 2019
2 parents 56286a0 + 355e379 commit 58a0bbc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions library/Requests/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ protected function normalize_attribute($name, $value) {
return $expiry_time;

case 'domain':
// Domains are not required as per RFC 6265 section 5.2.3
if (empty($value)) {
return null;
}

// Domain normalization, as per RFC 6265 section 5.2.3
if ($value[0] === '.') {
$value = substr($value, 1);
Expand Down
9 changes: 8 additions & 1 deletion tests/Cookies.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,13 @@ public function parseFromHeadersProvider() {
array( 'invalid' => false ),
),

# Empty Domain
array(
'name=value; domain=',
'http://example.com/test/',
array(),
),

# Subdomain cookies
array(
'name=value; domain=test.example.com',
Expand Down Expand Up @@ -639,4 +646,4 @@ public function testParsingHeaderWithOrigin($header, $origin, $expected, $expect
$cookie = reset($parsed);
$this->check_parsed_cookie($cookie, $expected, $expected_attributes, $expected_flags);
}
}
}

0 comments on commit 58a0bbc

Please sign in to comment.