File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
src/Symfony/Component/Security/Http Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -160,7 +160,12 @@ public function clearRememberMeCookie(): void
160160 return ;
161161 }
162162
163- $ rememberMeDetails = RememberMeDetails::fromRawCookie ($ cookie );
163+ try {
164+ $ rememberMeDetails = RememberMeDetails::fromRawCookie ($ cookie );
165+ } catch (AuthenticationException ) {
166+ // malformed cookie should not fail the response and can be simply ignored
167+ return ;
168+ }
164169 [$ series ] = explode (': ' , $ rememberMeDetails ->getValue ());
165170 $ this ->tokenProvider ->deleteTokenBySeries ($ series );
166171 }
Original file line number Diff line number Diff line change @@ -74,6 +74,22 @@ public function testClearRememberMeCookie()
7474 $ this ->assertNull ($ cookie ->getValue ());
7575 }
7676
77+ public function testClearRememberMeCookieMalformedCookie ()
78+ {
79+ $ this ->tokenProvider ->expects ($ this ->exactly (0 ))
80+ ->method ('deleteTokenBySeries ' );
81+
82+ $ this ->request ->cookies ->set ('REMEMBERME ' , 'malformed ' );
83+
84+ $ this ->handler ->clearRememberMeCookie ();
85+
86+ $ this ->assertTrue ($ this ->request ->attributes ->has (ResponseListener::COOKIE_ATTR_NAME ));
87+
88+ /** @var Cookie $cookie */
89+ $ cookie = $ this ->request ->attributes ->get (ResponseListener::COOKIE_ATTR_NAME );
90+ $ this ->assertNull ($ cookie ->getValue ());
91+ }
92+
7793 public function testConsumeRememberMeCookieValid ()
7894 {
7995 $ this ->tokenProvider ->expects ($ this ->any ())
You can’t perform that action at this time.
0 commit comments