<< Back to previous view

[DJSON-22] Improper parsing of numbers - leading zeroes should be disallowed Created: 28/Jul/15  Updated: 30/Jul/15

Status: Open
Project: data.json
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Matthew Gilliard Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File djson-22.patch    

 Description   

Handling of numeric literals doesn't perform according to the JSON spec.

Example:

(require '[clojure.data.json :as json])
(json/read-str "0123")
(json/read-str "{\"num\": 0123}")

Both of these examples parse the number as 123. According to the spec, this should actually be an invalid number and throw an exception. NB this restriction does not seem to apply to a number in the exponent, so a number like 1e0003 should be parsed as 1000.0. We handle this case correctly now.



 Comments   
Comment by Matthew Gilliard [ 30/Jul/15 10:34 AM ]

Fix + Tests. Feedback welcome.





[DJSON-21] Improper parsing of literals Created: 07/Jul/15  Updated: 28/Jul/15

Status: Open
Project: data.json
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Mike Sukmanowsky Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Handling of numeric literals doesn't perform according to the JSON spec.

Example:

(require '[clojure.data.json :as json])
(json/read-str "123abc")

Returns the number 1232. According to the spec, this should actually be an invalid literal and throw an exception:



 Comments   
Comment by Matthew Gilliard [ 28/Jul/15 5:39 PM ]

(I assume there's a typo in the description - 123 is returned, not 1232)

It's not just literal values, non-whitespace at the end of any input is silently ignored and should be rejected:

(json/read-str "{}xxx")   =>  {}
(json/read-str "[]yyy")   =>  []
(json/read-str "\"\"zzz") =>  ""

NB This behaviour agrees with the docstring ("Reads a single item of JSON data from ...").





Generated at Thu Jul 30 13:26:34 CDT 2015 using JIRA 4.4#649-r158309.