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

WordPress Trac noreply at wordpress.org
Sun Nov 2 18:12:57 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 TobiasBg):

 Replying to [comment:38 pento]:
 > I think our better option is to fix the places that call
 `wp_json_encode()`, to ensure proper type checking.

 I agree. This is much better than having `wp_json_encode()` not return
 false, which can be checked for to initiate error handling. If
 `wp_json_encode()` returns valid JSON (in terms of "empty" valid JSON)
 where `json_encode()` returns false, it would no longer be a drop-in
 replacement.
 There would be no good way to find out if a `wp_json_encode()` return
 value like `""` is the result of valid input (like an empty string), or
 the result of "wrong" input, that just could not be encoded.

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


More information about the wp-trac mailing list