[Pkg-owncloud-commits] [owncloud] 86/95: Only read php://input when parameters are requested
David Prévot
taffit at moszumanska.debian.org
Wed Mar 11 15:49:52 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v8.0.1
in repository owncloud.
commit 75cae3b2527e4af6369009401936ba5be0b89178
Author: Lukas Reschke <lukas at owncloud.com>
Date: Fri Feb 27 17:56:40 2015 +0100
Only read php://input when parameters are requested
Less invasive version of https://github.com/owncloud/core/pull/14574 for stable8 as requested at https://github.com/owncloud/core/issues/14283#issuecomment-76402295
Alarm: Major hack detected :see_no_evil:
---
lib/private/appframework/http/request.php | 39 +++++++++++++++++++++++--------
1 file changed, 29 insertions(+), 10 deletions(-)
diff --git a/lib/private/appframework/http/request.php b/lib/private/appframework/http/request.php
index 6012033..7dcb063 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
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list