Closed Bug 929879 Opened 11 years ago Closed 11 years ago

System JS : ERROR (null):0, JSON.parse: expected double-quoted property name with LANG=fi_FI

Categories

(Core :: DOM: Core & HTML, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla27

People

(Reporter: romaxa, Assigned: smaug)

Details

Attachments

(1 file)

On attempt to parse this string:
data:{ "x" : 0, "y" : 0, "viewport" : { "width" : 360,000000, "height" : 560,000000 }, "displayPort" : { "x" : 0,000000, "y" : 0,000000, "width" : 360,000000, "height" : 560,000000 }, "compositionBounds" : { "x" : 0, "y" : 0, "width" : 540, "height" : 840 }, "cssPageRect" : { "x" : 0,000000, "y" : 0,000000, "width" : 360,000000, "height" : 560,000000 }, "cssCompositedRect" : { "width" : 360,000000, "height" : 560,000000 } }

with LANG=fi_FI, I see error:
"System JS : ERROR (null):0, JSON.parse: expected double-quoted property name"


#0  xpc::SystemErrorReporter (cx=<optimized out>, message=0x4870bea6 "system javascript", rep=0x4b1fe470)
    at mozilla-central/js/xpconnect/src/nsXPConnect.cpp:270
#1  0x483ff5fc in js_ReportErrorAgain (cx=0x4d29e420, message=0x4ffa0508 "JSON.parse: expected double-quoted property name", reportp=0x4b1fe470)
    at mozilla-central/js/src/jscntxt.cpp:903
#2  0x483ff7dc in js_ReportErrorNumberVA (cx=0x4d29e420, flags=1879048186, callback=0x483fd118 <js_GetErrorMessage(void*, char const*, unsigned int)>, userRef=0x0, 
    errorNumber=228, argumentsType=js::ArgumentsAreASCII, ap=...) at mozilla-central/js/src/jscntxt.cpp:832
#3  0x483e11e4 in JS_ReportErrorNumberVA (cx=<optimized out>, errorCallback=<optimized out>, userRef=<optimized out>, errorNumber=<optimized out>, ap=...)
    at mozilla-central/js/src/jsapi.cpp:5647
#4  0x483e120c in JS_ReportErrorNumber (cx=<optimized out>, errorCallback=<optimized out>, userRef=<optimized out>, errorNumber=228)
    at mozilla-central/js/src/jsapi.cpp:5636
#5  0x4846f6e8 in error (msg=0x48a47898 "expected double-quoted property name", this=<optimized out>)
    at mozilla-central/js/src/jsonparser.cpp:63
#6  error (msg=0x48a47898 "expected double-quoted property name", this=<optimized out>) at mozilla-central/js/src/jsonparser.cpp:457
#7  js::JSONParser::advancePropertyName (this=<optimized out>) at mozilla-central/js/src/jsonparser.cpp:471
#8  0x4846f9a4 in js::JSONParser::parse (this=0x4b1fe558, vp=...) at mozilla-central/js/src/jsonparser.cpp:635
#9  0x48468f78 in js::ParseJSONWithReviver (cx=0x4d29e420, chars=..., length=<optimized out>, reviver=..., vp=...)
    at mozilla-central/js/src/json.cpp:783
#10 0x483e111c in JS_ParseJSON (cx=<optimized out>, chars=<optimized out>, len=<optimized out>, vp=...)
    at mozilla-central/js/src/jsapi.cpp:5600

branch FIREFOX_AURORA_26_BASE:

Pretty much sure same should be reproducible with current TabChild on windows Metro or b2g.
The input data is not valid JSON, the decimal separator is wrong. Here is a shorter version to reproduce the SyntaxError:
> `JSON.parse('{ "width" : 360,000000 }')`

Instead of `360,000000`, the value needs to be `360.000000`.
Yeah, unfortunately JS uses US localization for decimal separator, not the one we use in Finland :)
Romaxa, did you get the error while running FF, or with your own thing?
In other words, should this bug be closed invalid, or moved to some other component.
Component: JavaScript Engine → General
Source of that string coming from http://mxr.mozilla.org/mozilla-central/source/dom/ipc/TabChild.cpp#1544
My guess it should be the same problem for Firefox too, because it will use same snprintf with in specific locale environment.
Uh
Component: General → DOM
Ok, nsString::AppendFloat should work here.
Attached patch patchSplinter Review
Use .AppendFloat/Literal/Printf
(we really should have a string builder)

https://tbpl.mozilla.org/?tree=Try&rev=737eb64bafc3
Assignee: nobody → bugs
Attachment #821841 - Flags: review?(romaxa)
Attachment #821841 - Flags: review?(romaxa) → review+
https://hg.mozilla.org/mozilla-central/rev/de201d14d2da
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla27
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: