Skip to content

Commit

Permalink
Merge branch '4.4' into 5.0
Browse files Browse the repository at this point in the history
* 4.4:
  [Http Foundation] Fix clear cookie samesite
  [Security] Check if firewall is stateless before checking for session/previous session
  [Form] Support customized intl php.ini settings
  [Security] Remember me: allow to set the samesite cookie flag
  [Debug] fix for PHP 7.3.16+/7.4.4+
  [Validator] Backport translations
  [Mailer] Use %d instead of %s for error code in error messages
  [HttpKernel] fix locking for PHP 7.4+
  [Security] Fixed hardcoded value of SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE
  Prevent warning in proc_open()
  [FrameworkBundle] Fix Router Cache
  Fix deprecation messages
  • Loading branch information
nicolas-grekas committed Mar 23, 2020
2 parents 6748a30 + 0a3b771 commit 2da0828
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ResponseHeaderBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ public function getCookies(string $format = self::COOKIES_FLAT)
/**
* Clears a cookie in the browser.
*/
public function clearCookie(string $name, ?string $path = '/', string $domain = null, bool $secure = false, bool $httpOnly = true)
public function clearCookie(string $name, ?string $path = '/', string $domain = null, bool $secure = false, bool $httpOnly = true, string $sameSite = null)
{
$this->setCookie(new Cookie($name, null, 1, $path, $domain, $secure, $httpOnly, false, null));
$this->setCookie(new Cookie($name, null, 1, $path, $domain, $secure, $httpOnly, false, $sameSite));
}

/**
Expand Down
8 changes: 8 additions & 0 deletions Tests/ResponseHeaderBagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ public function testClearCookieSecureNotHttpOnly()
$this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; Max-Age=0; path=/; secure', $bag);
}

public function testClearCookieSamesite()
{
$bag = new ResponseHeaderBag([]);

$bag->clearCookie('foo', '/', null, true, false, 'none');
$this->assertSetCookieHeader('foo=deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; Max-Age=0; path=/; secure; samesite=none', $bag);
}

public function testReplace()
{
$bag = new ResponseHeaderBag([]);
Expand Down

0 comments on commit 2da0828

Please sign in to comment.