Closed Bug 383574 Opened 19 years ago Closed 14 years ago

regexp /\0/ triggers bogus strict warning "non-octal digit in an escape sequence that doesn't match a back-reference"

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: jruderman, Assigned: x00000000)

References

Details

(Keywords: testcase)

Attachments

(1 file, 1 obsolete file)

js> options("strict") js> "foo\0bar".replace(/\0/, "NULL") typein:2: strict warning: non-octal digit in an escape sequence that doesn't match a back-reference: typein:2: strict warning: "foo\0bar".replace(/\0/, "NULL") typein:2: strict warning: ...................^ fooNULLbar \0 seems to be a recommended way to search for null characters (see http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:RegExp), so I think this warning is bogus.
Depends on: 306727
Assignee: general → crowder
Severity: minor → normal
Status: NEW → ASSIGNED
Blocks: 296661
x00000000: I think a patch of yours from another bug fixes this. If I'm right, let's dup?
Attached patch patch (obsolete) — Splinter Review
(In reply to comment #1) > x00000000: I think a patch of yours from another bug fixes this. No, bug 429243 looks similar, but isn't related. The patch is not fully tested yet. Regarding bug 306727 comment 12: Specified behavior for /\01/ would be the same as for /01/. \0 in a DecimalEscape cannot be followed by a DecimalDigit because a DecimalIntegerLiteral cannot start with 0, unless it is only the single digit 0, and treating it as /0x001/ is prohibited by the lookahead (although that would make most sense to me). That means it has to be parsed as IdentityEscape instead. If Appendix B.1.2 would apply to RegExp literals (makes sense if it applies to strings), then /\08/ should still be /08/, and the octal digits eat never more than 3 digits, so /\0001/ should be /\x001/ like "\0001" is "\x001". /\001/ would be /\x01/, however.
Assignee: crowder → x00000000
Attachment #317862 - Attachment is obsolete: true
Comment on attachment 318087 [details] [diff] [review] patch that doesn't break /\100/ Is this awaiting review, or does it need more testing?
js> "foo\0bar".replace(/\0/, "NULL") "fooNULLbar"
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Flags: in-testsuite?
Resolution: --- → WORKSFORME
OS: Mac OS X → All
Hardware: x86 → All
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: