ClojureScript

cljs.reader should js js/parseInt with radix specified

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

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

Activity

Hide
Dave Della Costa added a comment -

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.

Show
Dave Della Costa added a comment - 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.
Hide
Francis Avila added a comment -

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.

Show
Francis Avila added a comment - 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.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: