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:
-rw-r--r--lib/private/appframework/http/request.php4
-rw-r--r--tests/lib/appframework/http/RequestTest.php21
2 files changed, 24 insertions, 1 deletions
diff --git a/lib/private/appframework/http/request.php b/lib/private/appframework/http/request.php
index cfd903bffe5..3e24eec37c8 100644
--- a/lib/private/appframework/http/request.php
+++ b/lib/private/appframework/http/request.php
@@ -410,7 +410,9 @@ class Request implements \ArrayAccess, \Countable, IRequest {
}
}
- $this->items['parameters'] = array_merge($this->items['parameters'], $params);
+ if (is_array($params)) {
+ $this->items['parameters'] = array_merge($this->items['parameters'], $params);
+ }
$this->contentDecoded = true;
}
diff --git a/tests/lib/appframework/http/RequestTest.php b/tests/lib/appframework/http/RequestTest.php
index f75e4578546..bb9910b6a46 100644
--- a/tests/lib/appframework/http/RequestTest.php
+++ b/tests/lib/appframework/http/RequestTest.php
@@ -202,6 +202,27 @@ class RequestTest extends \Test\TestCase {
$this->assertSame('Joey', $request['nickname']);
}
+ public function testNotJsonPost() {
+ global $data;
+ $data = 'this is not valid json';
+ $vars = array(
+ 'method' => 'POST',
+ 'server' => array('CONTENT_TYPE' => 'application/json; utf-8')
+ );
+
+ $request = new Request(
+ $vars,
+ $this->secureRandom,
+ $this->getMock('\OCP\Security\ICrypto'),
+ $this->config,
+ $this->stream
+ );
+
+ $this->assertEquals('POST', $request->method);
+ $result = $request->post;
+ // ensure there's no error attempting to decode the content
+ }
+
public function testPatch() {
global $data;
$data = http_build_query(array('name' => 'John Q. Public', 'nickname' => 'Joey'), '', '&');