Skip to content

Commit

Permalink
Merge pull request #1998 from curtisdf/master
Browse files Browse the repository at this point in the history
A better fix for #1894 - "Undefined offset: 0"
  • Loading branch information
sagikazarmark committed Mar 26, 2018
2 parents 9e6a3fa + 64976eb commit 8ffb1d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Cookie/SetCookie.php
Expand Up @@ -35,8 +35,8 @@ public static function fromString($cookie)
$data = self::$defaults;
// Explode the cookie string using a series of semicolons
$pieces = array_filter(array_map('trim', explode(';', $cookie)));
// The name of the cookie (first kvp) must include an equal sign.
if (empty($pieces) || !strpos($pieces[0], '=')) {
// The name of the cookie (first kvp) must exist and include an equal sign.
if (empty($pieces[0]) || !strpos($pieces[0], '=')) {
return new self($data);
}

Expand Down
1 change: 1 addition & 0 deletions tests/Cookie/SetCookieTest.php
Expand Up @@ -224,6 +224,7 @@ public function cookieParserDataProvider()
),
array('', []),
array('foo', []),
array('; foo', []),
array(
'foo="bar"',
[
Expand Down

0 comments on commit 8ffb1d2

Please sign in to comment.