Skip to main content

Bug Tracker

Side navigation

#1152 closed bug (duplicate)

Opened April 30, 2007 06:11PM UTC

Closed August 15, 2008 06:43PM UTC

Safari (not Webkit) crashes with $(<toomuchtext>)

Reported by: martin.heidegger Owned by:
Priority: major Milestone: 1.3
Component: core Version: 1.2.6
Keywords: Cc:
Blocked by: Blocking:
Description

If you have a too long string (even valid) in $("... here ..."); then safari crashes with a pretty ugly

exception. Notice: this does not happen in Webkit.

I came over this problem by loading some > 8k page via ajax and applying some subpart of the content to the $(), in order to search through it.

My problem could be fixed by changing from

var content = $(myContent);

for (var i=0; i<content.length; i++) {

do some operation to all nodes of the html block

}

to

var div = document.createElement("div");

div.innerHTML = myContent;

for (var i=0; i<div.childNodes.length; i++) {

do some operation to all nodes of the html block

}

Attachments (0)
Change History (5)

Changed August 25, 2007 03:00AM UTC by arrix comment:1

This is related to the safari bug which causes a crash when the regular expression is too long. See http://tobielangel.com/2007/4/18/yet-another-safari-bug

The bug has been fixed in Webkit nightly.

Changed October 31, 2007 08:59PM UTC by soenke comment:2

we changed in jquery.js

var m = /^[^<]*(<(.|\\s)+>)[^>]*$/.exec(a);

if ( m )

a = jQuery.clean( [ m[1] ] );

else

return new jQuery( c ).find( a );

to:

if (navigator.userAgent.indexOf("Konqueror") > -1

|| navigator.userAgent.indexOf("Safari") > -1)

{

var lp = a.indexOf('<');

var rp = a.length - 1;

while (rp >= 0 && a[rp] != '>') { --rp; }

if (lp > -1 && rp > lp) {

var b = a.substring (lp, rp + 1);

a = jQuery.clean( [ b ] );

}

else

return new jQuery( c ).find( a );

}

else

{

var m = /^[^<]*(<(.|\\s)+>)[^>]*$/.exec(a);

if ( m )

a = jQuery.clean( [ m[1] ] );

else

return new jQuery( c ).find( a );

}

This works fine in safari2/3, Firefox2, ie6, ie7, Oper9, and KDE3-Konqueror

Changed November 02, 2007 08:02AM UTC by soenke comment:3


		if ( typeof a  == "string" ) {
			// HANDLE: $(html) -> $(array)

				var lp = a.indexOf('<');
				var rp = a.lastIndexOf('>');
				if (lp > -1 && rp > lp) {
					    var b = a.substring (lp, rp + 1);
					    a = jQuery.clean( [ b ] );
				}
				else
					return new jQuery( c ).find( a );
		}

Changed August 14, 2008 05:21PM UTC by nathanhammon comment:4

This bug may be out of date. The same basic problem is exhibiting itself on ticket 3178.

Changed August 15, 2008 06:43PM UTC by john comment:5

description: If you have a too long string (even valid) in $("... here ..."); then safari crashes with a pretty ugly \ exception. Notice: this does not happen in Webkit.\ \ I came over this problem by loading some > 8k page via ajax and applying some subpart of the content to the $(), in order to search through it.\ \ My problem could be fixed by changing from\ \ var content = $(myContent);\ \ for (var i=0; i<content.length; i++) {\ // do some operation to all nodes of the html block\ }\ \ to\ \ var div = document.createElement("div");\ div.innerHTML = myContent;\ \ for (var i=0; i<div.childNodes.length; i++) {\ // do some operation to all nodes of the html block\ }If you have a too long string (even valid) in $("... here ..."); then safari crashes with a pretty ugly \ exception. Notice: this does not happen in Webkit. \ \ I came over this problem by loading some > 8k page via ajax and applying some subpart of the content to the $(), in order to search through it. \ \ My problem could be fixed by changing from \ \ var content = $(myContent); \ \ for (var i=0; i<content.length; i++) { \ // do some operation to all nodes of the html block \ } \ \ to \ \ var div = document.createElement("div"); \ div.innerHTML = myContent; \ \ for (var i=0; i<div.childNodes.length; i++) { \ // do some operation to all nodes of the html block \ }
milestone: 1.1.31.3
resolution: → duplicate
status: newclosed
version: 1.1.21.2.6

Duplicate of [3178].