Fix case sensitive sameSite cookie
This commit is contained in:
parent
e33beda8db
commit
14c310f5fb
@ -77,6 +77,10 @@ class Cookie
|
|||||||
$this->httpOnly = (bool) $httpOnly;
|
$this->httpOnly = (bool) $httpOnly;
|
||||||
$this->raw = (bool) $raw;
|
$this->raw = (bool) $raw;
|
||||||
|
|
||||||
|
if (null !== $sameSite) {
|
||||||
|
$sameSite = strtolower($sameSite);
|
||||||
|
}
|
||||||
|
|
||||||
if (!in_array($sameSite, array(self::SAMESITE_LAX, self::SAMESITE_STRICT, null), true)) {
|
if (!in_array($sameSite, array(self::SAMESITE_LAX, self::SAMESITE_STRICT, null), true)) {
|
||||||
throw new \InvalidArgumentException('The "sameSite" parameter value is not valid.');
|
throw new \InvalidArgumentException('The "sameSite" parameter value is not valid.');
|
||||||
}
|
}
|
||||||
|
@ -180,4 +180,10 @@ class CookieTest extends TestCase
|
|||||||
$this->assertTrue($cookie->isRaw());
|
$this->assertTrue($cookie->isRaw());
|
||||||
$this->assertEquals('foo=b+a+r; path=/', (string) $cookie);
|
$this->assertEquals('foo=b+a+r; path=/', (string) $cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSameSiteAttributeIsCaseInsensitive()
|
||||||
|
{
|
||||||
|
$cookie = new Cookie('foo', 'bar', 0, '/', null, false, true, false, 'Lax');
|
||||||
|
$this->assertEquals('lax', $cookie->getSameSite());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user