Skip to content

Commit b9b68b4

Browse files
authored
Merge pull request #338 from SerheyDolgushev/fix_sign_null_cookie
fix: Added support for cookies with null value
2 parents 9ae9fab + f5418bf commit b9b68b4

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

phpstan-baseline.neon

-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ parameters:
2525
count: 1
2626
path: src/EventListener/FlexibleSslListener.php
2727

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

3329
-
3430
message: "#^Method Nelmio\\\\SecurityBundle\\\\UserAgent\\\\UAFamilyParser\\\\PsrCacheUAFamilyParser\\:\\:getUaFamily\\(\\) should return string but returns mixed\\.$#"

src/EventListener/SignedCookieListener.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function onKernelResponse(ResponseEvent $e): void
7474
$response->headers->removeCookie($cookie->getName(), $cookie->getPath(), $cookie->getDomain());
7575
$signedCookie = new Cookie(
7676
$cookie->getName(),
77-
$this->signer->getSignedValue($cookie->getValue()),
77+
$this->signer->getSignedValue((string) $cookie->getValue()),
7878
$cookie->getExpiresTime(),
7979
$cookie->getPath(),
8080
$cookie->getDomain(),

tests/Listener/SignedCookieListenerTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function provideCookieReading(): array
6363
[['foo'], ['foo' => 'bar'], []],
6464
[['foo'], ['foo' => 'bar.ca3756f81d3728a023bdc8a622c0906f373b795e'], ['foo' => 'bar']],
6565
[['*'], ['foo' => 'bar.ca3756f81d3728a023bdc8a622c0906f373b795e'], ['foo' => 'bar']],
66+
[['*'], ['foo' => '.25af6174a0fcecc4d346680a72b7ce644b9a88e8'], ['foo' => '']],
6667
];
6768
}
6869

@@ -101,6 +102,7 @@ public function provideCookieWriting(): array
101102
[[], ['foo' => 'bar'], ['foo' => 'bar']],
102103
[['foo'], ['foo' => 'bar'], ['foo' => 'bar.ca3756f81d3728a023bdc8a622c0906f373b795e']],
103104
[['*'], ['foo' => 'bar'], ['foo' => 'bar.ca3756f81d3728a023bdc8a622c0906f373b795e']],
105+
[['*'], ['foo' => null], ['foo' => '.25af6174a0fcecc4d346680a72b7ce644b9a88e8']],
104106
];
105107
}
106108

0 commit comments

Comments
 (0)