Steffen
Well-known member
- Affected version
- 2.3.7
To reproduce, send JSON input to XenForo that PHP's
Then
Possible fix:
json_decode function does not turn into an array (but into a string/int/boolean/...). For example:
Code:
curl -X POST -H "Content-Type: application/json" -d "true" https://xenforo.com/community/
Then
XF\Http\Request::getPhpInputJson returns a scalar value (instead of an array) which causes the following error in XF\Http\Request::__construct:
Code:
Uncaught TypeError: Unsupported operand types: array + bool in src/XF/Http/Request.php:912
Possible fix:
Diff:
--- a/src/XF/Http/Request.php
+++ b/src/XF/Http/Request.php
@@ -963,7 +963,8 @@ class Request
$rawInput = @file_get_contents("php://input");
if ($rawInput)
{
- return json_decode($rawInput, true) ?: [];
+ $json = json_decode($rawInput, true);
+ return is_array($json) ? $json : [];
}
}