diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-07-06 12:29:07 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-07-06 12:29:07 +0200 |
commit | 073e6546922c1b326a1ea733e9505e2350419590 (patch) | |
tree | 69c3d3b4b4abfc0d128c5a412e162cde3ca756b6 /lib | |
parent | 4dbc8ab77fb9aa45f250302a46c4146d63ea0cc2 (diff) | |
parent | 62e3de1bdb5df865cf9bbf833273b015b3513989 (diff) | |
download | nextcloud-server-073e6546922c1b326a1ea733e9505e2350419590.tar.gz nextcloud-server-073e6546922c1b326a1ea733e9505e2350419590.zip |
Merge pull request #17304 from owncloud/fix-17265
Check if response could get generated
Diffstat (limited to 'lib')
-rw-r--r-- | lib/public/appframework/http/jsonresponse.php | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/public/appframework/http/jsonresponse.php b/lib/public/appframework/http/jsonresponse.php index 1a770109d45..456a5616d4d 100644 --- a/lib/public/appframework/http/jsonresponse.php +++ b/lib/public/appframework/http/jsonresponse.php @@ -61,9 +61,16 @@ class JSONResponse extends Response { * Returns the rendered json * @return string the rendered json * @since 6.0.0 + * @throws \Exception If data could not get encoded */ - public function render(){ - return json_encode($this->data); + public function render() { + $response = json_encode($this->data); + 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; } /** |