Bug #68546 [ReO]: json_decode() Fatal error: Cannot access property started with '\0'

From: Date: Fri, 05 Dec 2014 01:54:04 +0000
Subject: Bug #68546 [ReO]: json_decode() Fatal error: Cannot access property started with '\0'
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188919@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68546&edit=1 ID: 68546 Updated by: requinix@php.net Reported by: j dot tvr at centrum dot cz Summary: json_decode() Fatal error: Cannot access property started with '\0' Status: Re-Opened Type: Bug Package: JSON related PHP Version: 5.6.3 Block user comment: N Private report: N New Comment: Ah, sorry, I forgot that json is an awkward extension with multiple underlying implementations. I was using jsonc on Ubuntu where it worked, but it does fail on Windows. Given that JSON is often passed as user input, I'd really like it if I could decode strings without worrying about fatal errors and continue with my input validation normally. Previous Comments: ------------------------------------------------------------------------ [2014-12-04 23:42:18] aharvey@php.net It does fail for me in the json_decode as well, although I'm _very_ on the fence about whether this is actually worth fixing. ------------------------------------------------------------------------ [2014-12-04 22:57:16] j dot tvr at centrum dot cz That code does NOT work fine, it is a bug in ext-json. Both jsonc (http://pecl.php.net/package/jsonc) and jsond (http://pecl.php.net/package/jsond) do not result in fatal error for the very same input. ------------------------------------------------------------------------ [2014-12-04 18:52:23] requinix@php.net *That* code works fine. $obj->{"\x00"} won't, which I assume is what you're actually trying to report. If you think your keys may have control characters, or in general characters not valid for property/variable names, then decode to an array instead. Just because JSON supports certain object keys doesn't mean PHP should too. ------------------------------------------------------------------------ [2014-12-04 16:37:48] j dot tvr at centrum dot cz Description: ------------ Calling json_decode may result in fatal error. Test script: --------------- json_decode('{"\u0000": 1}'); Expected result: ---------------- It should not result in fatal error. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68546&edit=1

« previous php.bugs (#188919) next »