Skip to content

Commit bb9db21

Browse files
committed
fix cookie issues
1 parent 4c7d118 commit bb9db21

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/Illuminate/Cookie/Middleware/EncryptCookies.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function decrypt(Request $request)
8383
$value = $this->decryptCookie($key, $cookie);
8484

8585
$request->cookies->set(
86-
$key, strpos($value, sha1($key).'|') !== 0 ? null : substr($value, 41)
86+
$key, strpos($value, sha1($key.'v2').'|') !== 0 ? null : substr($value, 41)
8787
);
8888
} catch (DecryptException $e) {
8989
$request->cookies->set($key, null);
@@ -142,7 +142,7 @@ protected function encrypt(Response $response)
142142
$response->headers->setCookie($this->duplicate(
143143
$cookie,
144144
$this->encrypter->encrypt(
145-
sha1($cookie->getName()).'|'.$cookie->getValue(),
145+
sha1($cookie->getName().'v2').'|'.$cookie->getValue(),
146146
static::serialized($cookie->getName())
147147
)
148148
));

src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ protected function getTokenFromRequest($request)
151151
$token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN');
152152

153153
if (! $token && $header = $request->header('X-XSRF-TOKEN')) {
154-
$token = $this->encrypter->decrypt($header, static::serialized());
154+
$token = substr($this->encrypter->decrypt($header, static::serialized()), 41);
155155
}
156156

157157
return $token;

src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,8 @@ protected function prepareCookiesForRequest()
560560
return array_merge($this->defaultCookies, $this->unencryptedCookies);
561561
}
562562

563-
return collect($this->defaultCookies)->map(function ($value) {
564-
return encrypt($value, false);
563+
return collect($this->defaultCookies)->map(function ($value, $key) {
564+
return encrypt(sha1($key.'v2').'|'.$value, false);
565565
})->merge($this->unencryptedCookies)->all();
566566
}
567567

0 commit comments

Comments
 (0)