1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-17 17:28:42 +01:00
phorge-phorge/externals/javelinjs/src
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
..
core Use direct inclusion, not submodules, to bring Javelin into Phabricator 2013-01-22 12:43:55 -08:00
docs Use direct inclusion, not submodules, to bring Javelin into Phabricator 2013-01-22 12:43:55 -08:00
ext Use direct inclusion, not submodules, to bring Javelin into Phabricator 2013-01-22 12:43:55 -08:00
lib Fix JSON encoding of PhutilSafeHTML for browser consumption 2013-01-28 18:11:27 -08:00