Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#6752 closed Bug (invalid)

Null pointer exception in selection/plugin.js

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


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.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.addRange( nativeRange );

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

Attachments (1)

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

Download all attachments as: .zip

Change History (4)

Changed 6 years ago by coyote

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

comment:1 Changed 6 years ago by garry.yao

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

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 6 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 6 years ago by wwalc

Duplicate of #6577.

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