Bug Tracker

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)

test.html (662 bytes) - added by Joachim 15 years ago.
Here is a sample test file to reproduce the behaviour
3178.html (742 bytes) - added by nathanhammond 15 years ago.
Updates test case that would have previously failed in Safari.
3178.diff (1.6 KB) - added by nathanhammond 15 years ago.
Patch for sanity check. Includes patch for Test Suite.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 15 years ago by flesler

need: PatchTest Case

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 ?

Changed 15 years ago by Joachim

Attachment: test.html added

Here is a sample test file to reproduce the behaviour

comment:2 Changed 15 years ago by Joachim

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 nathanhammon

It is this line that it is choking on in jQuery.fn.init(): var match = quickExpr.exec( selector );

Process:

  1. Calls jQuery.fn.init(html, context);
  2. jQuery.fn.init() decides to not do anything on the first time through and try it again as jQuery.fn.init(context).find(selector);
  3. 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:

  1. Test this in other versions of Safari Win (who has a different version?).
  2. Test this on Safari Mac (all versions supported).

comment:4 Changed 15 years ago by nathanhammon

The total length limit appears to be 49996. Not even divisible by 8!

comment:5 Changed 15 years ago by nathanhammon

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 nathanhammond

Attachment: 3178.html added

Updates test case that would have previously failed in Safari.

Changed 15 years ago by nathanhammond

Attachment: 3178.diff added

Patch for sanity check. Includes patch for Test Suite.

comment:6 Changed 14 years ago by dmethvin

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 dmethvin

Resolution: fixed
Status: newclosed

The regexp optimizations applied here should have fixed the performance issue: http://github.com/jquery/jquery/commit/9dc6e0c572b9c809a3a4c123071d96d48a01dd1c#L2L20

Note: See TracTickets for help on using tickets.