Bug Tracker

Ticket #1152 (closed bug: duplicate)

Opened 2 years ago

Last modified 7 months ago

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

Reported by: martin.heidegger Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.3 Component: core
Version: 1.2.6 Keywords:
Cc: Needs: Review

Description (last modified by john) (diff)

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

Change History

Changed 2 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.

Changed 2 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

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

Changed 11 months ago by nathanhammon

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

Changed 11 months ago by john

  • status changed from new to closed
  • version changed from 1.1.2 to 1.2.6
  • resolution set to duplicate
  • description changed from 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 } to 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 changed from 1.1.3 to 1.3

Duplicate of [3178].

Note: See TracTickets for help on using tickets.