Closed Bug 633677 Opened 14 years ago Closed 13 years ago

TM: regexp too complex

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

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.
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
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
Reopened per comment 2.
Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---
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.
(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
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.
Depends on: 625600
Status: REOPENED → RESOLVED
Closed: 14 years ago13 years ago
Resolution: --- → DUPLICATE
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.