Bug Tracker

Opened 13 years ago

Closed 12 years ago

#1152 closed bug (duplicate)

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 (last modified by john)

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

}

Change History (5)

comment:1 Changed 12 years ago by arrix

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.

comment:2 Changed 12 years ago by soenke

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

comment:3 Changed 12 years ago by soenke

		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 );
		}

comment:4 Changed 12 years ago by nathanhammon

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

comment:5 Changed 12 years ago by john

Description: modified (diff)
Milestone: 1.1.31.3
Resolution: duplicate
Status: newclosed
Version: 1.1.21.2.6

Duplicate of [3178].

Note: See TracTickets for help on using tickets.