Skip to content

Commit

Permalink
Fix for #1894 - "Undefined offset: 0"
Browse files Browse the repository at this point in the history
  • Loading branch information
Curtis Farnham committed Jan 31, 2018
1 parent aa5b807 commit 64976eb
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 @@ -223,6 +223,7 @@ public function cookieParserDataProvider()
),
array('', []),
array('foo', []),
array('; foo', []),
array(
'foo="bar"',
[
Expand Down

0 comments on commit 64976eb

Please sign in to comment.