Opened 14 years ago

Closed 9 years ago

#5659 closed Bug (worksforme)

Selection plugin keeps crashing

Reported by: Antti Leppä Owned by:
Priority: Low Milestone:
Component: General Version: 3.2.1
Keywords: Cc:

Description

CKEditor keeps crashing in background with Firefox because selection plugin uses "tryThese" to check if browser supports "createRange" function.

Crashing can be avoided by refactoring code to use typeof operator instead of tryThese.

plugins/selection/plugin.js:743

var self = this;

var node = CKEDITOR.tools.tryThese(
// Is it native IE control type selection?
function()
{
	return self.getNative().createRange().item( 0 );
},
// Figure it out by checking if there's a single enclosed
// node of the range.
function()
{
	var range  = self.getRanges()[ 0 ];
	range.shrink( CKEDITOR.SHRINK_ELEMENT );
 
	var enclosed;
	if ( range.startContainer.equals( range.endContainer )
		&& ( range.endOffset - range.startOffset ) == 1
		&& styleObjectElements[ ( enclosed = range.startContainer.getChild( range.startOffset ) ).getName() ] )
	{
		return enclosed.$;
	}
});

Would be replaced with:

var node = null; 	
// Is it native IE control type selection?
if (this.getNative() && (typeof this.getNative().createRange == "function")) {
  node = this.getNative().createRange().item( 0 );
} else {
  var range = this.getRanges()[ 0 ];
  range.shrink( CKEDITOR.SHRINK_ELEMENT );
  var enclosed;
  if ( range.startContainer.equals( range.endContainer ) 
    && ( range.endOffset - range.startOffset ) == 1 
    && styleObjectElements[ ( enclosed = range.startContainer.getChild( range.startOffset ) ).getName() ] ) 
  {
    node = enclosed.$;
  }
}

The bug was discovered with Firefox 3.5.9 (Firebug 1.5.4) / Linux 64bit

Attachments (3)

ie11_version.png (28.6 KB) - added by Wiktor Walc 9 years ago.
self.png (64.4 KB) - added by Wiktor Walc 9 years ago.
self_getNative.png (49.9 KB) - added by Wiktor Walc 9 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 12 years ago by Jakub Ś

Resolution: worksforme
Status: newclosed

I was not able to crash editor in 64-bit Linux using latest CKEditor 3.6.2

This post is 2 years old and "tryThese" has changed the lot. Look like this has expired.
If anyone is able to reproduce it please reopen this ticket.

comment:2 Changed 9 years ago by Wiktor Walc

Resolution: worksforme
Status: closedreopened

Encountered the same on IE 11

Changed 9 years ago by Wiktor Walc

Attachment: ie11_version.png added

Changed 9 years ago by Wiktor Walc

Attachment: self.png added

Changed 9 years ago by Wiktor Walc

Attachment: self_getNative.png added

comment:3 Changed 9 years ago by Wiktor Walc

Resolution: worksforme
Status: reopenedclosed

Uh, turned out I had IE debugger configured to break on all exceptions.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy