Closed
Bug 633677
Opened 14 years ago
Closed 13 years ago
TM: regexp too complex
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
DUPLICATE
of bug 625600
People
(Reporter: cdleary, Unassigned)
References
Details
Taken from bug 592569 comment 3:
Here is my RegExp (you can just paste it in firebug and it will throw the
error):
/^[a-zA-Z0-9_.+-=?^#]{1,64}@(([a-zA-Z0-9-]){1,251}.){1,252}[a-zA-Z0-9]{2,4}$/
So, as for the description of this bug:
Steps to Reproduce:
1. paste this into the address bar:
javascript:(function(){x=/^[a-zA-Z0-9_.+-=?^#]{1,64}@(([a-zA-Z0-9-]){1,251}.){1,252}[a-zA-Z0-9]{2,4}$/;alert("foo")})()
2. press enter
Actual Results:
In Firefox 4.0b10pre running under Ubuntu 10.10 32-bit, it throws a "regular
expression is too complex" error in the console (without a line number).
Expected Results:
I would expect "foo" to appear in an alert box.
Reporter | ||
Comment 1•14 years ago
|
||
This pattern's bytecode is too large for the PCRE engine to handle. This part in particular: (([a-zA-Z0-9-]){1,251}.){1,252}
Fixed number repetitions are expanded in the PCRE compiler, so this winds up with quite a large bytecode space.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → WONTFIX
Comment 2•14 years ago
|
||
What do other modern browsers do with such a regexp? We may need to support this at some point for interop, so keeping the bug open seems better for now. It is an artifact of PCRE, which we hope to ditch, and it may draw dups.
/be
Reporter | ||
Comment 3•14 years ago
|
||
Reopened per comment 2.
Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---
Comment 4•14 years ago
|
||
Here's another testcase for this bug:
http://www.computec.de/firefox4b_js_test.html
The textarea contains some JSON-encoded HTML, a typical response from a XMLHttpRequest.
Steps to reproduce:
1. Open testcase url in Firefox 4.0b12 (Win/32Bit), click the submit button -> throws "regular expression is too complex".
2. Remove at least 68 characters from the textarea to have less than 335654 characters left (keeping the JSON format intact), click submit button -> success
So the bug also pertains to the length of the text that a sufficient complex RegExp is run against.
The Regexp used in this testcase comes from a ColdFusion 8 setup (/cfiscripts/ajax/package/cfajax.js). It's used to validate a JSON-encoded response. If that fails, any AJAX-based web application that returns HTML > 330 KByte will stop working. I think this is a major problem.
Comment 5•14 years ago
|
||
(In reply to comment #2)
> What do other modern browsers do with such a regexp?
Dunno about other browsers, but somewhat general solutions are well known[1].
[1] http://swtch.com/~rsc/regexp/regexp1.html
Comment 6•14 years ago
|
||
Unfortunately this bug still exists with Firefox 4.0 final. For us it is a showstopper, we'll have to advise our users to avoid an upgrade until it is fixed.
Updated•13 years ago
|
Status: REOPENED → RESOLVED
Closed: 14 years ago → 13 years ago
Resolution: --- → DUPLICATE
Comment 8•13 years ago
|
||
I can confirm this bug is fixed, at least in the latest nightly (9.0a1 (2011-09-15)).
This RegExp no longer throws an exception: /^[a-zA-Z0-9_.+-=?^#]{1,64}@(([a-zA-Z0-9-]){1,251}.){1,252}[a-zA-Z0-9]{2,4}$/
You need to log in
before you can comment on or make changes to this bug.
Description
•