W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2012

[Bug 19778] New: Wrong regex for integer

From: <bugzilla@jessica.w3.org>
Date: Tue, 30 Oct 2012 13:50:20 +0000
To: public-script-coord@w3.org
Message-ID: <bug-19778-3890@http.www.w3.org/Bugs/Public/>
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

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:07 UTC