1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-29 08:50:58 +01:00
phorge-phorge/src/aphront
epriestley fc4cb57357 Fix JSON encoding of PhutilSafeHTML for browser consumption
Summary:
If you run this code:

  json_encode(array('tag' => phutil_tag('div', array())));

...you get this result, because json_encode() does not call toString() on objects:

  {"tag":{}}

Instead, convert such objects to their underlying strings. Javelin has support for JX.HTML and for implicit conversion (which is kind of sketchy for other reasons) but it's sort of complicated (only happens on Ajax, not behaviors) and messy (not metadata-based), so ignore it for now.

We'll need to do something similar for serialization to the database. My plan there is just to throw on any objects. The only time we put HTML in the database is cache-related and those tiny number of callsites can manually handle it.

Test Plan: Various ajax things now receive the correct data.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Maniphest Tasks: T2432

Differential Revision: https://secure.phabricator.com/D4684
2013-01-28 18:11:27 -08:00
..
__tests__ Add passthru to AphrontRequest 2012-12-11 17:27:02 -08:00
configuration Convert phutil_render_tag(X, Y, phutil_escape_html(Z)) to phutil_tag 2013-01-24 19:08:55 -08:00
console Add javelin_tag(), convert easy callsites 2013-01-25 12:57:17 -08:00
exception Delete license headers from files 2012-11-05 11:16:51 -08:00
response Fix JSON encoding of PhutilSafeHTML for browser consumption 2013-01-28 18:11:27 -08:00
sink Share more HTTPSink code 2012-12-25 06:17:45 -08:00
AphrontController.php Throw instead of log for invalid properties 2012-12-18 16:15:01 -08:00
AphrontRequest.php Don't require phabricator.base-uri to be configured 2013-01-22 13:57:02 -08:00
AphrontURIMapper.php Delete license headers from files 2012-11-05 11:16:51 -08:00