Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Posselt <Raydiation@users.noreply.github.com>2015-02-27 21:52:42 +0300
committerBernhard Posselt <Raydiation@users.noreply.github.com>2015-02-27 21:52:42 +0300
commit95cfc4185ac5629f3fcf4ca2d83d1ca972e54ade (patch)
tree9e6fb9df2aaf6faa57cb1fcd313592b715ee569e
parentc78b5453ff2315992fc7fb563e28c4d3ecfa9959 (diff)
parent75cae3b2527e4af6369009401936ba5be0b89178 (diff)
Merge pull request #14587 from owncloud/fix/14283
Only read php://input when parameters are requested
-rw-r--r--lib/private/appframework/http/request.php39
1 files changed, 29 insertions, 10 deletions
diff --git a/lib/private/appframework/http/request.php b/lib/private/appframework/http/request.php
index 6012033fe52..7dcb063bcbd 100644
--- a/lib/private/appframework/http/request.php
+++ b/lib/private/appframework/http/request.php
@@ -48,6 +48,7 @@ class Request implements \ArrayAccess, \Countable, IRequest {
'method',
'requesttoken',
);
+ protected $streamReadInitialized = false;
/**
* @param array $vars An associative array with the following optional values:
@@ -86,16 +87,6 @@ class Request implements \ArrayAccess, \Countable, IRequest {
$this->items['post'] = $params;
}
}
- // Handle application/x-www-form-urlencoded for methods other than GET
- // or post correctly
- } elseif($vars['method'] !== 'GET'
- && $vars['method'] !== 'POST'
- && strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') !== false) {
-
- parse_str(file_get_contents($this->inputStream), $params);
- if(is_array($params)) {
- $this->items['params'] = $params;
- }
}
$this->items['parameters'] = array_merge(
@@ -276,6 +267,7 @@ class Request implements \ArrayAccess, \Countable, IRequest {
* @return mixed the content of the array
*/
public function getParam($key, $default = null) {
+ $this->initializeStreamParams();
return isset($this->parameters[$key])
? $this->parameters[$key]
: $default;
@@ -287,10 +279,36 @@ class Request implements \ArrayAccess, \Countable, IRequest {
* @return array the array with all parameters
*/
public function getParams() {
+ $this->initializeStreamParams();
return $this->parameters;
}
/**
+ * Workaround for ownCloud 8 to only read the stream-input when parameters
+ * are requested. For the next master release this is removed and implemented
+ * using a different approach.
+ */
+ protected function initializeStreamParams() {
+ if(
+ $this->streamReadInitialized === false &&
+ $this->getMethod() !== 'GET' &&
+ $this->getMethod() !== 'POST' &&
+ strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') !== false
+ ) {
+ $params = [];
+ parse_str(file_get_contents($this->inputStream), $params);
+ if(!empty($params)) {
+ $this->items['params'] = $params;
+ $this->items['parameters'] = array_merge(
+ $this->items['parameters'],
+ $this->items['params']
+ );
+ }
+ }
+ $this->streamReadInitialized = true;
+ }
+
+ /**
* Returns the method of the request
* @return string the method of the request (POST, GET, etc)
*/
@@ -337,6 +355,7 @@ class Request implements \ArrayAccess, \Countable, IRequest {
* @throws \LogicException
*/
protected function getContent() {
+ $this->initializeStreamParams();
// If the content can't be parsed into an array then return a stream resource.
if ($this->method === 'PUT'
&& strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') === false