Skip to content

Commit 5734dd3

Browse files
committed
apply changes from code review
1 parent dd3df69 commit 5734dd3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

system/Security/Security.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ private function removeTokenInRequest(RequestInterface $request): void
325325
} else {
326326
$body = $request->getBody() ?? '';
327327
$json = json_decode($body);
328-
if (! empty($json) && json_last_error() === JSON_ERROR_NONE) {
328+
if ($json !== null && json_last_error() === JSON_ERROR_NONE) {
329329
// We kill this since we're done and we don't want to pollute the JSON data.
330330
unset($json->{$this->config->tokenName});
331331
$request->setBody(json_encode($json));
@@ -356,7 +356,7 @@ private function getPostedToken(RequestInterface $request): ?string
356356

357357
if ($body !== '') {
358358
$json = json_decode($body);
359-
if (! empty($json) && json_last_error() === JSON_ERROR_NONE) {
359+
if ($json !== null && json_last_error() === JSON_ERROR_NONE) {
360360
return $json->{$this->config->tokenName} ?? null;
361361
}
362362

user_guide_src/source/libraries/security.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ The order of checking the availability of the CSRF token is as follows:
206206
3. ``php://input`` (JSON request) - bear in mind that this approach is the slowest one since we have to decode JSON and then re-encode it
207207
4. ``php://input`` (raw body) - for PUT, PATCH, and DELETE type of requests
208208

209+
.. note:: ``php://input`` (raw body) is checked since v4.4.2.
210+
209211
*********************
210212
Other Helpful Methods
211213
*********************

0 commit comments

Comments
 (0)