mozilla/rhino — pull request #62 by anba (2012-07-11 18:49:07+00:00)
Title: Fix bug 686806: JSONParser parses invalid JSON input

- trailing commas aren't allowed in object/array literals per JSON spec
- avoid using Integer.parseInt() to parse unicode escape sequences since parseInt() also accepts non-ASCII digits
- also avoid using Character.isDigit() in readNumber() for the very same reason
- readString() always created a StringBuilder instance to collect the input data, obviously this is actually only necessary when the input contains escaped characters. Therefore I've changed readString() to take the same approach as used in jsonparser.cpp
- the JSON number specification is stricter than Double.parseDouble(), for example Double.parseDouble() accepts the input string '10.'. To ensure only valid JSON number literals are passed to Double.parseDouble(), readNumber() was refactored to perform the necessary input validation.