On Sat, 23 Jun 2012 21:53:01 +0200, Stas Malyshev <smalys...@sugarcrm.com>
wrote:
Hi!
The warning for invalid UTF-8 stays intact and is thrown also with
display_errors = On. If this behavior is undesired this can be remedied
later.
Must we discuss it 1000 times anew? There was a reason why it didn't
throw warning when display_errors is on. The reason is that it is very
easy to feed the server configured with display_errors = on wrong JSON
and thus force it to reveal information, and this is largely beyond the
control of application writer.
I find this argument unconvincing.
If json_encode() is not supposed to receive badly encoded data, then it's
the application writer's responsibility to make sure that the data is
correctly encoded. If, on the other hand, you think that's actually not a
error on the part of the caller to call json_encode() with badly encoded
data (i.e., just like htmlspecialchars() -- from which I removed the
warning removed in 5.4 --, json_encode() also accumulates the
responsibility validating some aspects of the input), then there's no
reason to have a warning at all.
In other words, if it's a precondition of json_encode() that the input is
correctly encoded (and the check is just a form of safe programming), then
there's indeed an error on the part of the application writer, if it
isn't, then there's no reason for any sort of warning.
(By the way, I'd prefer no warning at all, both for this and for inf/NAN.
We already can get the error from json_last_error() if we want to)
--
Gustavo Lopes
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php