ZF-8616: Zend_Json_Encoder does not block invalid UTF-8 as expected


In JSON, the presence of invalid Unicode should produce an error. In the case of PHP's ext/json it instead returns NULL (presumably to avoid unnecessary errors). Zend_Json_Encoder, the PHP native implementation used either by choice or in the absence of ext/json does neither, instead pulling out what appears to be a codepoint reference. This gives rise to invalid JSON strings in that such refs are lost and presented as literal characters.

Reproduce with:

require_once 'Zend/Json/Encoder.php';
$source = <<

Expected (as per ext/json):





No comments to display