Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting individual list elements from Firefox on Windows fails #3415

Closed
jackwickham opened this issue Sep 14, 2019 · 3 comments
Closed

Pasting individual list elements from Firefox on Windows fails #3415

jackwickham opened this issue Sep 14, 2019 · 3 comments
Labels
browser:firefox The issue can only be reproduced in the Firefox browser. plugin:clipboard The plugin which probably causes the issue. status:confirmed An issue confirmed by the development team. type:bug A bug.
Milestone

Comments

@jackwickham
Copy link
Contributor

jackwickham commented Sep 14, 2019

Type of report

Bug

Provide detailed reproduction steps (if any)

  1. Copy a fragment of a list using Firefox on Windows. For example, given a list with elements A, B, C and D, copying just B and C will produce clipboard contents
<html><body>
<!--StartFragment--><li>
		B
	</li>
	<li>
		C
	</li><!--EndFragment-->
</body>
</html>

(per https://evercoder.github.io/clipboard-inspector/ as well as dev tool stepping through)

  1. Paste this into a CKEditor instance

Expected result

The paste succeeds, inserting

  • B
  • C

Actual result

TypeError: maybeBlockData is undefined

Root cause

This error appears to be caused because within the clipboard plugin, in _stripHtml, the regexes that strip the above snippet trim the <html>, <body> and <!--(Start|End)Fragment-->, but they don't trim the whitespace between <body> and <!--StartFragment-->, and between <!--EndFragment--> and </body>. The trimmed result therefore has leading and trailing whitespace.

When this makes its way to core/editable.js, processDataForInsertion, this triggers the leading/trailing whitespace check, so it is prepended and appended with a protection span, so it looks like

<span data-cke-marker="1">&nbsp;</span>
<li>
		B
	</li>
	<li>
		C
	</li>
<span data-cke-marker="1">&nbsp;</span>

This is then parsed as HTML. As it stands it isn't valid HTML, because there are bare <li>s without a <ul>. When Firefox parses it, it fixes it up as well as it can, to produce HTML equivalent to

<span data-cke-marker="1">&nbsp;</span>
<ul>
    <li>
        B
    </li>
    <li>
        C
    </li>
    <span data-cke-marker="1">&nbsp;</span>
</ul>

When you then trim the first and last elements of this, to drop the spans that are supposed to be leading and trailing, this deletes everything and causes the rest of the code to break.

Other details

  • Browser: Firefox 69 (I believe it only started occurring in 68 or 69)
  • OS: Windows 10 (this does not occur in Linux)
  • CKEditor version: 4.6.0
  • Installed CKEditor plugins: clipboard
@jackwickham jackwickham added the type:bug A bug. label Sep 14, 2019
jackwickham added a commit to jackwickham/ckeditor-dev that referenced this issue Sep 14, 2019
jackwickham added a commit to jackwickham/ckeditor-dev that referenced this issue Sep 14, 2019
@Comandeer
Copy link
Member

I can confirm that the issue is present only in Firefox and only on Windows.

@Comandeer Comandeer added browser:firefox The issue can only be reproduced in the Firefox browser. plugin:clipboard The plugin which probably causes the issue. labels Sep 15, 2019
jackwickham added a commit to jackwickham/ckeditor-dev that referenced this issue Sep 15, 2019
jackwickham added a commit to jackwickham/ckeditor-dev that referenced this issue Sep 15, 2019
@jacekbogdanski jacekbogdanski added the status:confirmed An issue confirmed by the development team. label Sep 17, 2019
@Comandeer
Copy link
Member

It seems to be connected with most basic issue, #3520.

Comandeer pushed a commit to jackwickham/ckeditor-dev that referenced this issue Oct 1, 2019
Comandeer pushed a commit to jackwickham/ckeditor-dev that referenced this issue Oct 1, 2019
@Comandeer
Copy link
Member

Closed in #3416.

@Comandeer Comandeer added this to the 4.13.1 milestone Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser:firefox The issue can only be reproduced in the Firefox browser. plugin:clipboard The plugin which probably causes the issue. status:confirmed An issue confirmed by the development team. type:bug A bug.
Projects
None yet
Development

No branches or pull requests

3 participants