mirror of
https://github.com/nextcloud/server.git
synced 2026-04-20 22:00:39 -04:00
fix: Only attempt to decode JSON input if it is not an empty string
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
e8bc35ec0a
commit
79f4e0de76
1 changed files with 7 additions and 4 deletions
|
|
@ -390,10 +390,13 @@ class Request implements \ArrayAccess, \Countable, IRequest {
|
|||
|
||||
// 'application/json' and other JSON-related content types must be decoded manually.
|
||||
if (preg_match(self::JSON_CONTENT_TYPE_REGEX, $this->getHeader('Content-Type')) === 1) {
|
||||
try {
|
||||
$params = json_decode(file_get_contents($this->inputStream), true, flags:JSON_THROW_ON_ERROR);
|
||||
} catch (\JsonException $e) {
|
||||
$this->decodingException = $e;
|
||||
$content = file_get_contents($this->inputStream);
|
||||
if ($content !== '') {
|
||||
try {
|
||||
$params = json_decode($content, true, flags:JSON_THROW_ON_ERROR);
|
||||
} catch (\JsonException $e) {
|
||||
$this->decodingException = $e;
|
||||
}
|
||||
}
|
||||
if (\is_array($params) && \count($params) > 0) {
|
||||
$this->items['params'] = $params;
|
||||
|
|
|
|||
Loading…
Reference in a new issue