[Bug 19778] New: Wrong regex for integer

https://www.w3.org/Bugs/Public/show_bug.cgi?id=19778

          Priority: P2
            Bug ID: 19778
                CC: mike@w3.org, public-script-coord@w3.org
          Assignee: cam@mcc.id.au
           Summary: Wrong regex for integer
        QA Contact: public-webapps-bugzilla@w3.org
          Severity: normal
    Classification: Unclassified
                OS: All
          Reporter: robin@w3.org
          Hardware: PC
            Status: NEW
           Version: unspecified
         Component: WebIDL
           Product: WebAppsWG

The current regex for integer is:

    /^-?(0([0-7]*|[Xx][0-9A-Fa-f]+)|[1-9][0-9]*)/

If you feed it something like 0xDEADBEEF, which is valid, it will not tokenise
properly. First, the leading 0 will match. Then it will enter the following
parentheses, where it will see [0-7]*. Since that is very happy to match
nothing, it succeeds and returns 0. You want:

    /^-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)/

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Received on Tuesday, 30 October 2012 13:50:26 UTC