-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Lone HTML <script> tags are stripped on paste #9659
Comments
#9674 addresses this |
… converting to DOM. Closes ckeditor#9659.
I was trying to reproduce this issue, but without success. It all depends on what is copied/pasted: Case 1: plain text is copied from equation input box → plain text is inserted _toDom.with.plain.text.mp4Case 2: HTML content is copied from editor view → HTML content is inserted _toDom.with.HTML.content.mp4It seems that it has nothing to do with the The same behavior can be observed in your isaul32/ckeditor5-math#34, where in the first video you copied & pasted plain text, but in the second video you copied & pasted HTML content. Please let me know if my conclusions are correct. |
@psmyrek The first video in the linked issue isaul32/ckeditor5-math#34 doesn't actually demonstrate this issue (#9659). Yes, copying and pasting plain text copies and pastes plain text, this is normal. As for your case 2, the one that is relevant to reproduce this issue: in your video you have |
@psmyrek Video demonstrating the bug 2021-06-24.15-52-00-00.00.25.000-00.00.58.333.mp4 |
Thanks for the clarification. I tried again, this time I think I followed the same steps as you did: I cloned However, I am still unable to reproduce this error on my side. The copied equation in my case is always a complete HTML content: ckeditor5-math.configured.to.use.script.mp4I've checked this issue in latest versions of Chrome, Firefox, Edge and Brave browsers and it works exactly the same in all of them, as I expected, but I wanted to make sure that the browser doesn't have any effect here. Could you help me reproduce this issue? Do you know what I did different than you? Did I miss something? |
@psmyrek I notice that you have Windows line endings ( |
@psmyrek Yes, this does in fact appear to be a Windows-specific behavior: https://docs.microsoft.com/en-us/windows/win32/dataxchg/html-clipboard-format |
Thanks @Jules-Bertholet for the hints, this could be OS-related issue indeed. |
📝 Provide detailed reproduction steps (if any)
I discovered this problem while debugging isaul32/ckeditor5-math#35. The plugin makes it easy to observe the incorrect behavior:
The issue is that when content is pasted,
_setupPasteDrop()
from
ClipboardPipeline
processes the content withHtmlDataProcessor
'stoView()
, which itself calls_toDom()
, which processes the pasted HTML via aDOMParser
:_toDom()
only retains nodes in thebody
ofDOMParser.parseFromString()
's response. However, when DOMParser encounters certain tags, like<script>
, that are alone and not surrounded by text, it places these tags in the<head>
and not the<body>
. Therefore, if plugins (like the aforementioned math plugin) use<script>
tags to store view elements, those elements can be stripped on paste.✔️ Expected result
All HTML tags are retained when content is pasted into CKEditor.
❌ Actual result
Lone
<script>
tags are stripped upon pasting into CKEditor.📃 Other details
If you'd like to see this fixed sooner, add a 👍 reaction to this post.
The text was updated successfully, but these errors were encountered: