diff --git a/src/Header/SetCookie.php b/src/Header/SetCookie.php index 532408cf8e..077d7bff3c 100644 --- a/src/Header/SetCookie.php +++ b/src/Header/SetCookie.php @@ -105,7 +105,7 @@ public static function fromString($headerLine, $bypassHeaderFieldName = false) $keyValuePairs = preg_split('#;\s*#', $headerLine); foreach ($keyValuePairs as $keyValue) { - if (preg_match('#^(?P[^=]+)=\s*("?)(?P[^"]+)\2#', $keyValue, $matches)) { + if (preg_match('#^(?P[^=]+)=\s*("?)(?P[^"]*)\2#', $keyValue, $matches)) { $headerKey = $matches['headerKey']; $headerValue= $matches['headerValue']; } else { diff --git a/test/Header/SetCookieTest.php b/test/Header/SetCookieTest.php index 9691316bfa..d47b1e64d3 100644 --- a/test/Header/SetCookieTest.php +++ b/test/Header/SetCookieTest.php @@ -486,6 +486,42 @@ public static function validCookieWithInfoProvider() array(), '' ), + array( + 'Set-Cookie: emptykey= ; Domain=docs.foo.com;', + array( + 'name' => 'myname', + 'value' => '', + 'domain' => 'docs.foo.com', + ), + 'emptykey=; Domain=docs.foo.com' + ), + array( + 'Set-Cookie: emptykey= ; Domain=docs.foo.com;', + array( + 'name' => 'myname', + 'value' => '', + 'domain' => 'docs.foo.com', + ), + 'emptykey=; Domain=docs.foo.com' + ), + array( + 'Set-Cookie: emptykey=; Domain=docs.foo.com;', + array( + 'name' => 'myname', + 'value' => '', + 'domain' => 'docs.foo.com', + ), + 'emptykey=; Domain=docs.foo.com' + ), + array( + 'Set-Cookie: emptykey; Domain=docs.foo.com;', + array( + 'name' => 'myname', + 'value' => '', + 'domain' => 'docs.foo.com', + ), + 'emptykey=; Domain=docs.foo.com' + ), ); } }