Opened 11 years ago
Last modified 7 years ago
#11562 confirmed Bug
allowedContent = true results in JS error when inserting elements
Reported by: | Tyler | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | Core : Editable | Version: | 4.0 |
Keywords: | Cc: |
Description (last modified by )
When config.allowedContent = true; is set, the editor throws a JS error when inserting content (such as an image) into any unknown element. A simple test case is this:
<nobr>a</nobr>
Steps to reproduce: With the above content entered into the editor, set the cursor focus to be inside the unknown tag, then insert an image.
Inside core/editable.js, the function extractNodesData
throws an error trying to look-up the allowed names for this element.
This is invalid HTML, so it is a user error, but the config.allowedContent = true;
prevents it from being filtered out (as it should). We've seen it pop-up when users are copy and pasting content from other sources. So at a minimum, I think the editor should handle this case in some way.
My suggestion is when allowedContent
is set to true, the editor should treat all unknown tags as a semantically meaning-less tag, perhaps inheriting the allowedNames
from DIV
elements.
I would be willing to submit a fix with the above suggestion, or implement another suggested fix if needed.
Thanks
Chrome error message:
Uncaught TypeError: Cannot read property 'img' of undefined ckeditor.js:319 c ckeditor.js:319 (anonymous function) ckeditor.js:326 CKEDITOR.editable.CKEDITOR.tools.createClass.proto.insertHtml ckeditor.js:300 (anonymous function) ckeditor.js:306 h ckeditor.js:10 CKEDITOR.event.CKEDITOR.event.fire ckeditor.js:11 CKEDITOR.editor.CKEDITOR.editor.fire ckeditor.js:13 CKEDITOR.tools.extend.insertHtml ckeditor.js:225 $.extend.editor.paste
Edit: This issue is about CKEditor throwing error if DTD was not extended.
Attachments (1)
Change History (5)
Changed 11 years ago by
Attachment: | 11562.html added |
---|
comment:2 Changed 11 years ago by
Status: | new → confirmed |
---|---|
Version: | 4.3.2 → 4.0 |
comment:3 Changed 7 years ago by
Description: | modified (diff) |
---|
comment:4 Changed 7 years ago by
Description: | modified (diff) |
---|
It's not a DUP of #10340. The issue can be reproduced on 11562.html but if
CKEDITOR.dtd
is correctly extended before editor initialization, everything works. Try e.g. placing this beforeCKEDITOR.replace
:Now there's no error. And #10340 is about cases in which DTD caching makes it impossible to extend it after loading CKEditor source.
However, I agree that CKEditor could not throw error if DTD was not extended. Not in every scenario it's predictable what will be inserted into editor and it's not a problem to default use some default DTD (span's or p's) when element cannot be found.