Re: json_encode() behavior for incorrectly encoded strings

From: Date: Thu, 21 Jun 2012 14:58:56 +0000
Subject: Re: json_encode() behavior for incorrectly encoded strings
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-60925@lists.php.net to get a copy of this message
On Thu, Jun 21, 2012 at 10:25 PM, Nikita Popov <nikita.ppv@googlemail.com> wrote: > On Thu, Jun 21, 2012 at 4:12 PM, Daniel Convissor > <danielc@analysisandsolutions.com> wrote: >> Hi Nikita: >> >>> PHP <= 5.3.13, PHP 5.4, master behave as follows when an invalid UTF-8 >>> string is encountered: >>>  * A warning is thrown, but only if display_errors=off >> >> So the warning is put into the error log?  But only if display_errors is >> off?  And if display_errors is on, no warning is produced? >> >> That's very counter-intuitive and un-PHP-like.  Someone mentioned it's for >> security reasons.  By that logic, we should get rid of all error >> messages because they all reveal some information that can be used by >> attackers. > > Yes, I agree with this, but other people thing differently about it ;) I think I must missed some infos, I though you was talking that you want to generate wanrings without regard of EG(display_errors). thanks > > Personally I'd actually remove the warning completely with the return > false behavior. The return value makes clear that there was an error > and json_last_error() can be used to determine what exactly went > wrong. The warning seems redundant in this case and could actually > make the use more complicated. > > Nikita > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > -- Laruence  Xinchen Hui http://www.laruence.com/

« previous php.internals (#60925) next »