File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -124,7 +124,12 @@ public function clearRememberMeCookie(): void
124124 return ;
125125 }
126126
127- $ rememberMeDetails = RememberMeDetails::fromRawCookie ($ cookie );
127+ try {
128+ $ rememberMeDetails = RememberMeDetails::fromRawCookie ($ cookie );
129+ } catch (AuthenticationException ) {
130+ // malformed cookie should not fail the response and can be simply ignored
131+ return ;
132+ }
128133 [$ series ] = explode (': ' , $ rememberMeDetails ->getValue ());
129134 $ this ->tokenProvider ->deleteTokenBySeries ($ series );
130135 }
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