Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
cljs.reader should js js/parseInt with radix specified
Description
In cljs.reader, the parse-int calls js/parseInt without a radix.
The radix is implementation defined if not specified. This causes problems for example in older Android browsers which parse "08" as 0 instead of 8.
This makes reading timestamps fail. For example: Trying to read: #inst "2013-07-08T21:00:00.000-00:00" causes: Error: timestamp day field must be in range 1..last day in month Failed: 1<=0<=31
in js console: parseInt("08") => 0 parseInt("08", 10) => 8
Just chiming in to mention that I have experienced this issue in Internet Explorer 8 and was going to submit a patch myself. Would be interested in getting this into the next version as for now we have a customized reader that we use to get past this.
Francis Avila
February 28, 2014 at 4:38 AM
Discovered integer-with-radix parsing problem but split it into CLJS-775 since it's not a simple parseInt issue.
This patch should fix ratio and inst parsing, but I don't have access to a browser which infers octals in parseInt.
Existing tests are sufficient to catch this problem for #inst.
There are no ratio tests for reader at all currently, but since ratios are shaky ground in cljs anyway I didn't add any.
In cljs.reader, the parse-int calls js/parseInt without a radix.
The radix is implementation defined if not specified.
This causes problems for example in older Android browsers which parse "08" as 0 instead of 8.
This makes reading timestamps fail. For example:
Trying to read: #inst "2013-07-08T21:00:00.000-00:00"
causes:
Error: timestamp day field must be in range 1..last day in month Failed: 1<=0<=31
in js console:
parseInt("08") => 0
parseInt("08", 10) => 8