Closed Bug 197451 Opened 22 years ago Closed 21 years ago

Nested quantifiers in regexp should be a syntax error

Categories

(Core :: JavaScript Engine, defect, P1)

x86
Windows 2000
defect

Tracking

()

VERIFIED FIXED
mozilla1.7final

People

(Reporter: keith, Assigned: brendan)

References

Details

(Keywords: fixed1.7, js1.5, Whiteboard: fixed-aviary1.0)

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312 /1{0,1}\({0,1}\d{3}\){0,1}{0,1}\-{0,1}\d{3}\-{0,1}\d{4}/ Notice the repeatition of the {0,1} half way through the above statement, mozilla constantly moved forward and never caught this problem, and the page worked fully within mozilla, however when trying the same page in ie it would constantly fail at this point. Mozilla should have noticed this error Reproducible: Always Steps to Reproduce: 1. repeat any section regular expression range code, mozilla never sees it, ie always does 2. 3. Actual Results: mozilla submits fine, ie fails Expected Results: should have failed and returned the line as invalid
The JavaScript debugger is an application you use to debug JavaScript, see http://www.mozilla.org/projects/venkman/. This has nothing to do with the debugger. Here's a simplified interaction... js> "XXXXX".match(/X{1,2}/) XX js> "XXXXX".match(/X{1,2}{1,2}/) XXXX And here's what perl has to say about it... $ perl -e '"XXXXX" =~ /(X{1,2})/; print "$1\n"' XX $ perl -e '"XXXXX" =~ /(X{1,2}{1,2})/; print "$1\n"' Nested quantifiers in regex; marked by <-- HERE in m/(X{1,2}{ <-- HERE 1,2})/ at -e line 1.
Assignee: rginda → rogerl
Status: UNCONFIRMED → NEW
Component: JavaScript Debugger → JavaScript Engine
Ever confirmed: true
Summary: Debugger doesn't catch regular expression errors that ie halts on → Nested quantifiers in regex should be a syntax error
QA Contact: caillon → pschwartau
Note: we already had a testcase in the JS testsuite to enforce SyntaxErrors on nested quantifiers. Unfortunately, I had only put cases treating the *, +, and ? operators. I have now added cases covering the {DecimalDigits} quantifier, as well: mozilla/js/tests/ecma_3/RegExp/regress-188206.js The testcase is failing not only in the current SpiderMonkey shell, but also in Rhino, and in SpiderMonkey even with the latest patch for bug 85721 applied (the big RegExp re-write). So that patch, as well as Rhino (where the rewrite has already been checked in), will have to be modified. My apologies for not having testing this case! The Rhino shell fails on different sections of the test than the ones I've added for this bug. That may have to do with the change we made in allowing braces, unescaped, as literal characters in regexp patterns. Even though this is ECMA-incorrect, we decided to follow Perl on this. It looks like Rhino never got that change. See bug 188206; bug 85721 comment 48; bug 190685
Depends on: RegExpPerf
Keywords: js1.5
Summary: Nested quantifiers in regex should be a syntax error → Nested quantifiers in regexp should be a syntax error
Need an error report for this case. /be
Assignee: rogerl → brendan
Severity: minor → normal
Priority: -- → P1
Target Milestone: --- → mozilla1.7final
Attached patch proposed fixSplinter Review
ECMA seems not to allow sentences that have quantifiers chained off the same term, so this patch replicates a js_ReportCompileErrorNumber call. If possible the code should consolidate the BAD_QUANTIFIER error detection. For now (1.7 final), this will do. /be
Attachment #148557 - Flags: superreview?(shaver)
Attachment #148557 - Flags: review?(igor)
I think this is good for 1.7 final. Reviewers will confirm, nominating bug. /be
Status: NEW → ASSIGNED
Flags: blocking1.7+
Oops, I meant result = JS_FALSE, not result = NULL, there in the first hunk. Please review accordingly. /be
Comment on attachment 148557 [details] [diff] [review] proposed fix aye. sr=shaver.
Attachment #148557 - Flags: superreview?(shaver) → superreview+
Comment on attachment 148557 [details] [diff] [review] proposed fix One level or review only for js/src, so I checked into the trunk. Going for 1.7 final approval, igor feel free to r+. /be
Attachment #148557 - Flags: approval1.7?
Comment on attachment 148557 [details] [diff] [review] proposed fix a=asa (on behalf of drivers) for checkin to 1.7
Attachment #148557 - Flags: approval1.7? → approval1.7+
Fixed on 1.7 branch and trunk -- ben and mscott will update the aviary1.0 branch later, they say. /be
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Keywords: fixed1.7
Resolution: --- → FIXED
Whiteboard: fixed-aviary1.0
Flags: testcase+
Attachment #148557 - Flags: review?(igor)
verified fixed.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: