Fix case sensitive sameSite cookie

This commit is contained in:
Mike Francis 2017-07-19 12:17:30 +01:00 committed by Fabien Potencier
parent e33beda8db
commit 14c310f5fb
2 changed files with 10 additions and 0 deletions

View File

@ -77,6 +77,10 @@ class Cookie
$this->httpOnly = (bool) $httpOnly;
$this->raw = (bool) $raw;
if (null !== $sameSite) {
$sameSite = strtolower($sameSite);
}
if (!in_array($sameSite, array(self::SAMESITE_LAX, self::SAMESITE_STRICT, null), true)) {
throw new \InvalidArgumentException('The "sameSite" parameter value is not valid.');
}

View File

@ -180,4 +180,10 @@ class CookieTest extends TestCase
$this->assertTrue($cookie->isRaw());
$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());
}
}