Skip to main content

Bug Tracker

Side navigation

#3178 closed bug (fixed)

Opened July 23, 2008 03:03PM UTC

Closed October 03, 2010 01:10AM UTC

[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)
  • 3178.diff (1.6 KB) - added by nathanhammond August 15, 2008 06:27PM UTC.

    Patch for sanity check. Includes patch for Test Suite.

  • 3178.html (0.7 KB) - added by nathanhammond August 15, 2008 04:32PM UTC.

    Updates test case that would have previously failed in Safari.

  • test.html (0.6 KB) - added by Joachim July 23, 2008 04:37PM UTC.

    Here is a sample test file to reproduce the behaviour

Change History (7)

Changed July 23, 2008 03:43PM UTC by flesler comment:1

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 July 23, 2008 04:43PM UTC by Joachim comment:2

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>

Changed August 14, 2008 04:26PM UTC by nathanhammon comment:3

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).

Changed August 14, 2008 04:34PM UTC by nathanhammon comment:4

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

Changed August 14, 2008 05:00PM UTC by nathanhammon comment:5

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 May 18, 2009 11:50PM UTC by dmethvin comment:6

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.

Changed October 03, 2010 01:10AM UTC by dmethvin comment:7

resolution: → fixed
status: newclosed

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