Opened 15 years ago
Closed 13 years ago
#3178 closed bug (fixed)
[Safari][Windows].html() with a text longer than 49934
Reported by: | Joachim | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.3 |
Component: | core | Version: | 1.2.6 |
Keywords: | safari windows | Cc: | |
Blocked by: | Blocking: |
Description
Hi,
I'm having a issue under Safari for windows version 3.1.2(525.21).
When i'm using thee following code
var data2 = ; var nb = 49934; for (cpt =0;cpt <nb;++cpt) {
data2 += 'a';
}
data2 = '<div><div id="website-background">taste</div><div>' + data2 + '</div></div>'; var currentSection = $('#website-background', data2).html(); console.log('Trace : ' + currentSection);
my currentSection var is filled whereas it's null if I use 49935 as nb
Attachments (3)
Change History (10)
comment:1 Changed 15 years ago by
need: | Patch → Test Case |
---|
Changed 15 years ago by
Here is a sample test file to reproduce the behaviour
comment:2 Changed 15 years ago by
I uploaded the file I used to reproduce the error.
I made a mistake in my first error description The length is 49935 + rhe length of <div><div id="website-background">taste</div><div></div></div>
comment:3 Changed 15 years ago by
It is this line that it is choking on in jQuery.fn.init(): var match = quickExpr.exec( selector );
Process:
- Calls jQuery.fn.init(html, context);
- jQuery.fn.init() decides to not do anything on the first time through and try it again as jQuery.fn.init(context).find(selector);
- It gets to the line mentioned above and fails to match.
That triggers the problem.
It looks like this might be a browser imposed limit to regex string length?
From here we need to:
- Test this in other versions of Safari Win (who has a different version?).
- Test this on Safari Mac (all versions supported).
comment:4 Changed 15 years ago by
The total length limit appears to be 49996. Not even divisible by 8!
comment:5 Changed 15 years ago by
It isn't us. https://bugs.webkit.org/show_bug.cgi?id=14873
IE: 67108863 Opera: 2097151 Safari: 49996 FF: ???
Not even in the same ballpark as the others.
Changed 15 years ago by
Updates test case that would have previously failed in Safari.
Changed 15 years ago by
Patch for sanity check. Includes patch for Test Suite.
comment:6 Changed 14 years ago by
Bug #4665 was related. The Webkit bug is now fixed according to their bug tracker above, but Nathan's patch seems like a good deal (even with a lower limit than 40,000 characters). Not execing a regexp on a monster string has got to be faster.
comment:7 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
The regexp optimizations applied here should have fixed the performance issue: http://github.com/jquery/jquery/commit/9dc6e0c572b9c809a3a4c123071d96d48a01dd1c#L2L20
Can you please provide a concise test case ? That is, a small html file with the minimum html/css/js necessary to reproduce the problem.
Also, does it happen for any number equal or higher than 49935 ?