Skip to content

Commit 4aa5b3b

Browse files
committed
formatting
1 parent ef82f51 commit 4aa5b3b

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/Illuminate/Cookie/CookieValuePrefix.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static function remove($cookieValue)
2828
}
2929

3030
/**
31-
* Validate a cookie value contains a valid prefix and return it without or null.
31+
* Validate a cookie value contains a valid prefix. If it does, return the cookie value with the prefix removed. Otherwise, return null.
3232
*
3333
* @param string $cookieName
3434
* @param string $cookieValue

src/Illuminate/Cookie/Middleware/EncryptCookies.php

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

86-
$request->cookies->set(
87-
$key, $this->validateValue($key, $value)
88-
);
86+
$request->cookies->set($key, $this->validateValue($key, $value));
8987
} catch (DecryptException $e) {
9088
$request->cookies->set($key, null);
9189
}
@@ -103,8 +101,9 @@ protected function decrypt(Request $request)
103101
*/
104102
protected function validateValue(string $key, $value)
105103
{
106-
return is_array($value) ? $this->validateArray($key, $value) :
107-
CookieValuePrefix::validate($key, $value, $this->encrypter->getKey());
104+
return is_array($value)
105+
? $this->validateArray($key, $value)
106+
: CookieValuePrefix::validate($key, $value, $this->encrypter->getKey());
108107
}
109108

110109
/**
@@ -116,12 +115,13 @@ protected function validateValue(string $key, $value)
116115
*/
117116
protected function validateArray(string $key, array $value)
118117
{
119-
$stripped = [];
120-
foreach ($value as $subKey => $subValue) {
121-
$stripped[$subKey] = $this->validateValue("${key}[${subKey}]", $subValue);
118+
$validated = [];
119+
120+
foreach ($value as $index => $subValue) {
121+
$validated[$index] = $this->validateValue("${key}[${index}]", $subValue);
122122
}
123123

124-
return $stripped;
124+
return $validated;
125125
}
126126

127127
/**
@@ -152,6 +152,7 @@ protected function decryptArray(array $cookie)
152152
if (is_string($value)) {
153153
$decrypted[$key] = $this->encrypter->decrypt($value, static::serialized($key));
154154
}
155+
155156
if (is_array($value)) {
156157
$decrypted[$key] = $this->decryptArray($value);
157158
}

0 commit comments

Comments
 (0)