From:             php at sameprecision dot org
Operating system: suse linux 10, windows XP sp2
PHP version:      5.2.1
PHP Bug Type:     Unknown/Other Function
Bug description:  json_encode ignores null byte started keys in arrays

Description:
------------
If a key in an array starts with the null byte, json_encode ignores that
key=>value pair.

This seems wrong because json_encode doesn't care about null bytes
anywhere in the value (and neither does javascript, about keys or values).

Reproduce code:
---------------
//works as expected:
echo json_encode(array(0,"a\0b"=>1,"\0null-prefixed value"));

echo "\n\n";

//ignores second element whose key begins with null byte:
echo json_encode(array(0,"\0ab"=>1,"\0null-prefixed value"));

Expected result:
----------------
{"0":0,"a\0b":1,"1":"\0null-prefixed value"}

{"0":0,"\0ab":1,"1":"\0null-prefixed value"}




// \0 represents an actual null byte here

Actual result:
--------------
{"0":0,"a\0b":1,"1":"\0null-prefixed value"}

{"0":0,"1":"\0null-prefixed value"}




// \0 represents an actual null byte here



-- 
Edit bug report at http://bugs.php.net/?id=41034&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41034&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41034&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41034&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=41034&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=41034&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=41034&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=41034&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=41034&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=41034&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=41034&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=41034&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=41034&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=41034&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41034&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=41034&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=41034&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=41034&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41034&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=41034&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=41034&r=mysqlcfg

Reply via email to