summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/public/AppFramework/Http/JSONResponse.php8
-rw-r--r--tests/lib/AppFramework/Http/JSONResponseTest.php6
2 files changed, 4 insertions, 10 deletions
diff --git a/lib/public/AppFramework/Http/JSONResponse.php b/lib/public/AppFramework/Http/JSONResponse.php
index f4b936435c8..4870a64afd7 100644
--- a/lib/public/AppFramework/Http/JSONResponse.php
+++ b/lib/public/AppFramework/Http/JSONResponse.php
@@ -64,13 +64,7 @@ class JSONResponse extends Response {
* @throws \Exception If data could not get encoded
*/
public function render() {
- $response = json_encode($this->data, JSON_HEX_TAG);
- if ($response === false) {
- throw new \Exception(sprintf('Could not json_encode due to invalid ' .
- 'non UTF-8 characters in the array: %s', var_export($this->data, true)));
- }
-
- return $response;
+ return json_encode($this->data, JSON_HEX_TAG | JSON_THROW_ON_ERROR);
}
/**
diff --git a/tests/lib/AppFramework/Http/JSONResponseTest.php b/tests/lib/AppFramework/Http/JSONResponseTest.php
index 504876b2d88..8c8318eb602 100644
--- a/tests/lib/AppFramework/Http/JSONResponseTest.php
+++ b/tests/lib/AppFramework/Http/JSONResponseTest.php
@@ -88,10 +88,10 @@ class JSONResponseTest extends \Test\TestCase {
$this->assertEquals($expected, $this->json->render());
}
-
+
public function testRenderWithNonUtf8Encoding() {
- $this->expectException(\Exception::class);
- $this->expectExceptionMessage('Could not json_encode due to invalid non UTF-8 characters in the array: array (');
+ $this->expectException(\JsonException::class);
+ $this->expectExceptionMessage('Malformed UTF-8 characters, possibly incorrectly encoded');
$params = ['test' => hex2bin('e9')];
$this->json->setData($params);