From:             
Operating system: Windows
PHP version:      5.3.13
Package:          JSON related
Bug Type:         Bug
Bug description:json_decode produces invalid byte-sequences

Description:
------------
It's a typical case the JSON *and* UTF-16 specifications warn about:
decoding of 
non-existing UTF-16 code-points:

    json_decode('"\ud834"')

shoud give NULL because \ud834 is *invalid*. But instead it starts some
party, 
get's boozed and offers this as UTF-8 byte-sequence:

    1110 1101  1010 0000  1011 0100
    1110 xxxx  10xx xxxx  10xx xxxx
               1101 1000  0011 0100
               D8         34

U+D834 is not a valid unicode character.



Test script:
---------------
if (NULL !== json_decode('"\ud834"')) {
    echo "json_decode is still broken.";
}

Expected result:
----------------
NULL because the json is invalid.

Actual result:
--------------
PHP tries to create UTF-8 out of it and fails by creating invalid UTF-8
unicode 
byte-sequences.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=62010&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=62010&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=62010&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=62010&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=62010&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=62010&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=62010&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=62010&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=62010&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=62010&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=62010&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=62010&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=62010&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=62010&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=62010&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=62010&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=62010&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=62010&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=62010&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=62010&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=62010&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=62010&r=mysqlcfg

Reply via email to