Skip to content

Commit 610a203

Browse files
authored
Merge pull request #36525 from nextcloud/fix/noid/params-put
fix: Only get params from PUT content if possible
2 parents 73495b0 + dc3916e commit 610a203

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/private/AppFramework/Http/Request.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ public function __get($name) {
260260
: null;
261261
case 'parameters':
262262
case 'params':
263+
if ($this->isPutStreamContent()) {
264+
return $this->items['parameters'];
265+
}
263266
return $this->getContent();
264267
default:
265268
return isset($this[$name])
@@ -391,12 +394,7 @@ public function getCookie(string $key) {
391394
*/
392395
protected function getContent() {
393396
// If the content can't be parsed into an array then return a stream resource.
394-
if ($this->method === 'PUT'
395-
&& $this->getHeader('Content-Length') !== '0'
396-
&& $this->getHeader('Content-Length') !== ''
397-
&& strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') === false
398-
&& strpos($this->getHeader('Content-Type'), 'application/json') === false
399-
) {
397+
if ($this->isPutStreamContent()) {
400398
if ($this->content === false) {
401399
throw new \LogicException(
402400
'"put" can only be accessed once if not '
@@ -411,6 +409,14 @@ protected function getContent() {
411409
}
412410
}
413411

412+
private function isPutStreamContent(): bool {
413+
return $this->method === 'PUT'
414+
&& $this->getHeader('Content-Length') !== '0'
415+
&& $this->getHeader('Content-Length') !== ''
416+
&& strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') === false
417+
&& strpos($this->getHeader('Content-Type'), 'application/json') === false;
418+
}
419+
414420
/**
415421
* Attempt to decode the content and populate parameters
416422
*/

0 commit comments

Comments
 (0)