1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-19 19:21:10 +01:00
phorge-phorge/src/aphront
epriestley 90294713e8 Use phutil_json_encode() in AphrontResponse to raise better errors
Summary:
Ref T11524. This problem was more difficult to diagnose than necessary because we swallow errors silently in `AphontResponse` when emitting JSON responses.

Instead of using `json_encode()`, use `phutil_json_encode()` which throws on failure.

Test Plan:
Old behavior was HTTP 200 with no body.

New behavior is HTTP 500 with this message:

```
[2016-08-26 07:33:59] EXCEPTION: (HTTPFutureHTTPResponseStatus) [HTTP/500] Internal Server Error
Exception: Failed to JSON encode value (#5: Malformed UTF-8 characters, possibly incorrectly encoded): Dictionary value at key "result" is not valid UTF8, and cannot be JSON encoded: diff --git a/latin1.txt b/latin1.txt
new file mode 100644
index 0000000..ce6c927
--- /dev/null
+++ b/latin1.txt
@@ -0,0 +1 @@
+<�>
. at [<phutil>/src/future/http/BaseHTTPFuture.php:339]
```

Reviewers: chad, avivey

Reviewed By: avivey

Maniphest Tasks: T11524

Differential Revision: https://secure.phabricator.com/D16457
2016-08-26 07:39:22 -07:00
..
__tests__ phtize all the things 2015-05-22 21:16:39 +10:00
configuration Don't apply security.require-https to intracluster requests 2016-04-13 12:51:41 -07:00
exception Convert some whiny exceptions into quiet MalformedRequest exceptions 2016-08-16 15:50:21 -07:00
handler Convert some whiny exceptions into quiet MalformedRequest exceptions 2016-08-16 15:50:21 -07:00
httpparametertype Smooth over a few more transaction compatibility/structure issues with Calendar events 2016-07-13 07:44:15 -07:00
interface Allow Controllers to return a wider range of "response-like" objects 2015-09-01 15:52:52 -07:00
response Use phutil_json_encode() in AphrontResponse to raise better errors 2016-08-26 07:39:22 -07:00
sink Extend from Phobject 2015-06-15 18:02:27 +10:00
site Don't apply security.require-https to intracluster requests 2016-04-13 12:51:41 -07:00
AphrontController.php Provide an AphrontController implementation of willSendResponse() 2015-09-07 17:18:35 -07:00
AphrontRequest.php Convert some whiny exceptions into quiet MalformedRequest exceptions 2016-08-16 15:50:21 -07:00