Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003189 [Quercus] minor always 12-17-08 23:45 12-18-08 09:35
Reporter koreth View Status public  
Assigned To nam
Priority normal Resolution fixed  
Status closed   Product Version 4.0.0
Summary 0003189: json_decode fails on primitive values
Description <?php
print_r(json_decode('5'));

Regular PHP prints "5". Quercus prints "Warning: error parsing '5': expected no more input [json_decode]".

The following patch seems to match PHP's behavior (though it doesn't detect numeric values, which may or may not be worth doing):

--- a/modules/quercus/src/com/caucho/quercus/lib/json/JsonDecoder.java
+++ b/modules/quercus/src/com/caucho/quercus/lib/json/JsonDecoder.java
@@ -51,6 +51,12 @@ class JsonDecoder {
 
     _isAssociative = assoc;
 
+ int c = skipWhitespace();
+ if (c != '[' && c != '{' && c != '"') {
+ return s;
+ }
+ unread();
+
     Value val = jsonDecodeImpl(env);
 
     // Should now be at end of string or have only white spaces left.
Additional Information
Attached Files

- Relationships

- Notes
(0003671)
nam
12-18-08 09:35

php/4720
 

- Issue History
Date Modified Username Field Change
12-17-08 23:45 koreth New Issue
12-18-08 08:50 nam Status new => assigned
12-18-08 08:50 nam Assigned To  => nam
12-18-08 09:35 nam Status assigned => closed
12-18-08 09:35 nam Note Added: 0003671
12-18-08 09:35 nam Resolution open => fixed
12-18-08 09:35 nam Fixed in Version  => 4.0.0


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
29 total queries executed.
26 unique queries executed.
Powered by Mantis Bugtracker