Skip to content

Commit

Permalink
Merge pull request #338 from SerheyDolgushev/fix_sign_null_cookie
Browse files Browse the repository at this point in the history
fix: Added support for cookies with null value
  • Loading branch information
Seldaek authored Mar 8, 2024
2 parents 9ae9fab + f5418bf commit b9b68b4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
4 changes: 0 additions & 4 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ parameters:
count: 1
path: src/EventListener/FlexibleSslListener.php

-
message: "#^Parameter \\#1 \\$value of method Nelmio\\\\SecurityBundle\\\\Signer\\:\\:getSignedValue\\(\\) expects string, string\\|null given\\.$#"
count: 1
path: src/EventListener/SignedCookieListener.php

-
message: "#^Method Nelmio\\\\SecurityBundle\\\\UserAgent\\\\UAFamilyParser\\\\PsrCacheUAFamilyParser\\:\\:getUaFamily\\(\\) should return string but returns mixed\\.$#"
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/SignedCookieListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function onKernelResponse(ResponseEvent $e): void
$response->headers->removeCookie($cookie->getName(), $cookie->getPath(), $cookie->getDomain());
$signedCookie = new Cookie(
$cookie->getName(),
$this->signer->getSignedValue($cookie->getValue()),
$this->signer->getSignedValue((string) $cookie->getValue()),
$cookie->getExpiresTime(),
$cookie->getPath(),
$cookie->getDomain(),
Expand Down
2 changes: 2 additions & 0 deletions tests/Listener/SignedCookieListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function provideCookieReading(): array
[['foo'], ['foo' => 'bar'], []],
[['foo'], ['foo' => 'bar.ca3756f81d3728a023bdc8a622c0906f373b795e'], ['foo' => 'bar']],
[['*'], ['foo' => 'bar.ca3756f81d3728a023bdc8a622c0906f373b795e'], ['foo' => 'bar']],
[['*'], ['foo' => '.25af6174a0fcecc4d346680a72b7ce644b9a88e8'], ['foo' => '']],
];
}

Expand Down Expand Up @@ -101,6 +102,7 @@ public function provideCookieWriting(): array
[[], ['foo' => 'bar'], ['foo' => 'bar']],
[['foo'], ['foo' => 'bar'], ['foo' => 'bar.ca3756f81d3728a023bdc8a622c0906f373b795e']],
[['*'], ['foo' => 'bar'], ['foo' => 'bar.ca3756f81d3728a023bdc8a622c0906f373b795e']],
[['*'], ['foo' => null], ['foo' => '.25af6174a0fcecc4d346680a72b7ce644b9a88e8']],
];
}

Expand Down

0 comments on commit b9b68b4

Please sign in to comment.