Skip to content

Commit

Permalink
disable serialization for all cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Aug 7, 2018
1 parent 7c90d41 commit 97467e3
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/Illuminate/Cookie/Middleware/EncryptCookies.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ class EncryptCookies
*/
protected $except = [];

/**
* The cookies that should not be serialized.
*
* @var array
*/
protected $serialization = [
'XSRF-TOKEN' => false,
];

/**
* Create a new CookieGuard instance.
*
Expand All @@ -43,8 +34,6 @@ class EncryptCookies
public function __construct(EncrypterContract $encrypter)
{
$this->encrypter = $encrypter;

$this->serialization[config('session.cookie')] = false;
}

/**
Expand Down Expand Up @@ -104,7 +93,7 @@ protected function decryptCookie($name, $cookie)
{
return is_array($cookie)
? $this->decryptArray($cookie)
: $this->encrypter->decrypt($cookie, $this->serialization[$name] ?? true);
: $this->encrypter->decrypt($cookie, false);
}

/**
Expand All @@ -119,7 +108,7 @@ protected function decryptArray(array $cookie)

foreach ($cookie as $key => $value) {
if (is_string($value)) {
$decrypted[$key] = $this->encrypter->decrypt($value, $this->serialization[$key] ?? true);
$decrypted[$key] = $this->encrypter->decrypt($value, false);
}
}

Expand All @@ -139,10 +128,8 @@ protected function encrypt(Response $response)
continue;
}

$serialize = $this->serialization[$cookie->getName()] ?? true;

$response->headers->setCookie($this->duplicate(
$cookie, $this->encrypter->encrypt($cookie->getValue(), $serialize)
$cookie, $this->encrypter->encrypt($cookie->getValue(), false)
));
}

Expand Down

0 comments on commit 97467e3

Please sign in to comment.