bug #23586 Fix case sensitive sameSite cookie (mikefrancis)

This PR was submitted for the master branch but it was merged into the 3.2 branch instead (closes #23586).

Discussion
----------

Fix case sensitive sameSite cookie

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23585
| License       | MIT
| Doc PR        |

Commits
-------

14c310f5fb Fix case sensitive sameSite cookie
This commit is contained in:
Fabien Potencier 2017-07-20 09:59:08 +02:00
commit 68582c0a9a
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());
}
}