Skip to content

Commit 68582c0

Browse files
committed
bug symfony#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 symfony#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 | symfony#23585 | License | MIT | Doc PR | Commits ------- 14c310f Fix case sensitive sameSite cookie
2 parents e33beda + 14c310f commit 68582c0

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/Symfony/Component/HttpFoundation/Cookie.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ public function __construct($name, $value = null, $expire = 0, $path = '/', $dom
7777
$this->httpOnly = (bool) $httpOnly;
7878
$this->raw = (bool) $raw;
7979

80+
if (null !== $sameSite) {
81+
$sameSite = strtolower($sameSite);
82+
}
83+
8084
if (!in_array($sameSite, array(self::SAMESITE_LAX, self::SAMESITE_STRICT, null), true)) {
8185
throw new \InvalidArgumentException('The "sameSite" parameter value is not valid.');
8286
}

src/Symfony/Component/HttpFoundation/Tests/CookieTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,10 @@ public function testRawCookie()
180180
$this->assertTrue($cookie->isRaw());
181181
$this->assertEquals('foo=b+a+r; path=/', (string) $cookie);
182182
}
183+
184+
public function testSameSiteAttributeIsCaseInsensitive()
185+
{
186+
$cookie = new Cookie('foo', 'bar', 0, '/', null, false, true, false, 'Lax');
187+
$this->assertEquals('lax', $cookie->getSameSite());
188+
}
183189
}

0 commit comments

Comments
 (0)