[wp-trac] [WordPress Trac] #28786: wp_send_json silently fails on non UTF-8 strings

WordPress Trac noreply at wordpress.org
Sun Nov 2 17:52:09 UTC 2014


#28786: wp_send_json silently fails on non UTF-8 strings
------------------------------+-----------------------
 Reporter:  pento             |       Owner:  pento
     Type:  defect (bug)      |      Status:  reopened
 Priority:  normal            |   Milestone:  4.1
Component:  Formatting        |     Version:  3.5
 Severity:  normal            |  Resolution:
 Keywords:  has-patch commit  |     Focuses:
------------------------------+-----------------------

Comment (by azaozz):

 Replying to [comment:38 pento]:
 > ...(to return 0 or an empty string on failure, perhaps)

 Right, also a "proper" JSON encoded value is `'false'`, `'0'`, `'""'`,
 etc. On the JS side JSON.parse() and jQuery.parseJSON() throw errors on
 empty string, int, etc.

 We should also handle the `false` returned from `wp_json_encode()` in
 `wp_send_json_success()` and `wp_send_json_error()`.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/28786#comment:39>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list