Ticket #6752 (closed Bug: invalid)

Opened 3 years ago

Last modified 3 years ago

Null pointer exception in selection/plugin.js

Reported by: coyote Owned by:
Priority: Normal Milestone:
Component: General Version: 3.4.2
Keywords: Cc: rlussier@…

Description

This happens for me, probably as a result of one or more custom plugins or skins I've written. The fix seems fairly easy, however, so I'm hoping that I can get you to incorporate it.

The following code is at the end of the selection plugin:

var selection = this.document.getSelection().getNative();
selection.removeAllRanges();
selection.addRange( nativeRange );

I'm seeing an error because 'selection' is null when the CKEditor is initialized. Adding a check as follows fixes the problem:

var selection = this.document.getSelection().getNative();
if (selection) {
   selection.removeAllRanges();
   selection.addRange( nativeRange );
}

I've attached my skin and custom plugins, just in case it helps you to confirm this.

Attachments

glassdoor ckeditor.zip (84.5 KB) - added by coyote 3 years ago.
plugins that I use, which might help if you want to reproduce.

Change History

Changed 3 years ago by coyote

plugins that I use, which might help if you want to reproduce.

comment:1 Changed 3 years ago by garry.yao

  • Status changed from new to closed
  • Resolution set to invalid

Thanks for the report, since we don't recommend interaction with the native selection directly but through CKEDITOR.dom.selection, so the case here is subjected to be checked by plugin developers.

comment:2 Changed 3 years ago by coyote

  • Cc rlussier@… added

You misunderstand the issue. My plugin is not interacting with the native selection at all. I traced through the CKEditor source code and found that call to "this.document.getSelection().getNative();" is returning a null value, which the next line of YOUR code then attempts to use without checking it.

Please don't dismiss this bug so cavalierly. It discourages users from bothering to file bugs.

comment:3 Changed 3 years ago by wwalc

Duplicate of #6577.

Note: See TracTickets for help on using tickets.
© 2003 – 2012 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy