mirror of
https://github.com/nextcloud/server.git
synced 2026-04-24 07:39:23 -04:00
fix: Only get params from PUT content if possible
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
528a79c34e
commit
119babd9a2
1 changed files with 12 additions and 6 deletions
|
|
@ -268,6 +268,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])
|
||||
|
|
@ -399,12 +402,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 '
|
||||
|
|
@ -419,6 +417,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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue