Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3a52e44

Browse filesBrowse files
bug #59 Fix SameSite attribute conversion from PSR7 to HttpFoundation (ajgarlag)
This PR was squashed before being merged into the 1.1-dev branch (closes #59). Discussion ---------- Fix SameSite attribute conversion from PSR7 to HttpFoundation Commits ------- 5ee1f8f Fix SameSite attribute conversion from PSR7 to HttpFoundation
2 parents f6d7d3a + 5ee1f8f commit 3a52e44
Copy full SHA for 3a52e44

File tree

2 files changed

+14
-2
lines changed
Filter options

2 files changed

+14
-2
lines changed

‎Factory/HttpFoundationFactory.php

Copy file name to clipboardExpand all lines: Factory/HttpFoundationFactory.php
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ private function createCookie($cookie)
210210

211211
continue;
212212
}
213+
214+
if ('samesite' === strtolower($name) && null !== $value) {
215+
$samesite = $value;
216+
217+
continue;
218+
}
213219
}
214220

215221
if (!isset($cookieName)) {
@@ -223,7 +229,9 @@ private function createCookie($cookie)
223229
isset($cookiePath) ? $cookiePath : '/',
224230
isset($cookieDomain) ? $cookieDomain : null,
225231
isset($cookieSecure),
226-
isset($cookieHttpOnly)
232+
isset($cookieHttpOnly),
233+
false,
234+
isset($samesite) ? $samesite : null
227235
);
228236
}
229237
}

‎Tests/Factory/HttpFoundationFactoryTest.php

Copy file name to clipboardExpand all lines: Tests/Factory/HttpFoundationFactoryTest.php
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Stream;
2020
use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\UploadedFile;
2121
use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Uri;
22+
use Symfony\Component\HttpFoundation\Cookie;
2223

2324
/**
2425
* @author Kévin Dunglas <dunglas@gmail.com>
@@ -199,7 +200,7 @@ public function testCreateResponse()
199200
'Set-Cookie' => array(
200201
'theme=light',
201202
'test',
202-
'ABC=AeD; Domain=dunglas.fr; Path=/kevin; Expires=Wed, 13 Jan 2021 22:23:01 GMT; Secure; HttpOnly',
203+
'ABC=AeD; Domain=dunglas.fr; Path=/kevin; Expires=Wed, 13 Jan 2021 22:23:01 GMT; Secure; HttpOnly; SameSite=Strict',
203204
),
204205
),
205206
new Stream('The response body'),
@@ -230,6 +231,9 @@ public function testCreateResponse()
230231
$this->assertEquals('/kevin', $cookies[2]->getPath());
231232
$this->assertTrue($cookies[2]->isSecure());
232233
$this->assertTrue($cookies[2]->isHttpOnly());
234+
if (defined('Symfony\Component\HttpFoundation\Cookie::SAMESITE_STRICT')) {
235+
$this->assertEquals(Cookie::SAMESITE_STRICT, $cookies[2]->getSameSite());
236+
}
233237

234238
$this->assertEquals('The response body', $symfonyResponse->getContent());
235239
$this->assertEquals(200, $symfonyResponse->getStatusCode());

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.