diff options
author | Julius Härtl <jus@bitgrid.net> | 2023-02-03 14:47:19 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2023-02-03 22:30:04 +0100 |
commit | dc3916e27c0693da85c354a999bf4e81518535a1 (patch) | |
tree | 2e9f40e9c0f95693f69f809f371231dc9d31f373 | |
parent | 1fed79982669f6e691ac3c799af1281662f0d2e9 (diff) | |
download | nextcloud-server-dc3916e27c0693da85c354a999bf4e81518535a1.tar.gz nextcloud-server-dc3916e27c0693da85c354a999bf4e81518535a1.zip |
fix: Only get params from PUT content if possible
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r-- | lib/private/AppFramework/Http/Request.php | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php index ac162f6565e..1f32d6c5461 100644 --- a/lib/private/AppFramework/Http/Request.php +++ b/lib/private/AppFramework/Http/Request.php @@ -260,6 +260,9 @@ class Request implements \ArrayAccess, \Countable, IRequest { : null; case 'parameters': case 'params': + if ($this->isPutStreamContent()) { + return $this->items['parameters']; + } return $this->getContent(); default: return isset($this[$name]) @@ -391,12 +394,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { */ protected function getContent() { // If the content can't be parsed into an array then return a stream resource. - if ($this->method === 'PUT' - && $this->getHeader('Content-Length') !== '0' - && $this->getHeader('Content-Length') !== '' - && strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') === false - && strpos($this->getHeader('Content-Type'), 'application/json') === false - ) { + if ($this->isPutStreamContent()) { if ($this->content === false) { throw new \LogicException( '"put" can only be accessed once if not ' @@ -411,6 +409,14 @@ class Request implements \ArrayAccess, \Countable, IRequest { } } + private function isPutStreamContent(): bool { + return $this->method === 'PUT' + && $this->getHeader('Content-Length') !== '0' + && $this->getHeader('Content-Length') !== '' + && strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') === false + && strpos($this->getHeader('Content-Type'), 'application/json') === false; + } + /** * Attempt to decode the content and populate parameters */ |