Problem/Motivation
<script> tags are stripped even when using the Full HTML
text format, or more generally: whenever there are zero HTML restrictions and hence even <script> should be allowed.
Steps to reproduce
Copy paste
<p>Hello</p>
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Feeling frustrated with myself for messing up what should've been a simple thing. Who's got furry friend pics? :)</p>— webchick (@webchick) <a href="https://twitter.com/webchick/status/1451664162291998720?ref_src=twsrc%5Etfw">October 22, 2021</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
<p>Bye!</p>
… and this <script> tag should not be lost upon save.
Proposed resolution
- ❌ We evaluated adding https://ckeditor.com/docs/ckeditor5/latest/features/html-embed.html to our build of CKEditor 5. It could have been a better way to deal with "random HTML snippets" such as social media embeds.
We tried, and concluded (see #12) that A) it generates additional wrapping mark-up (which is an unacceptable regression compared to both CKEditor 4 in D8|9 and CKEditor 5 in HEAD), B) it still does not prevent losing
<script>markup (which is the regression in HEAD, when upgrading from CKEditor 4 to 5). - ✅ Fix GHS upstream. This does not yield the beautiful UX that the HTML Embed CKEditor 5 plugin would have given us (or rather, that we were hoping for), but it still fixes the problem at hand: the critical data loss bug.
Remaining tasks
Working PoC.Dig intohtml-embeddocs to see if we can tweak its configuration to make it do what we needWork to get upstream fix in https://github.com/ckeditor/ckeditor5/issues/10891Confirmed that the upstream fix works: #27- Wait for the January 26, 2022 release of CKEditor 5: #26 + #27
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | 3245950-test-upstream-24.patch | 1.5 MB | lauriii |
| #12 | Screenshot 2021-11-16 at 16.52.16.png | 24.07 KB | wim leers |
| #12 | Screenshot 2021-11-16 at 16.52.08.png | 20.42 KB | wim leers |
Issue fork drupal-3245950
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3245950-html-embed-cke5-plugin
changes, plain diff MR !1419
1 hidden branch
Issue fork ckeditor5-3245950
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3245950-evaluate-adding-the
changes, plain diff MR !166
Comments
Comment #2
wim leersLet's do this after we update to the latest CKE5 release (shipped today): #3245942: Update CKEditor 5 to 31.0.0.
Comment #3
wim leersThis is unblocked.
Comment #5
yash.rode commentedComment #7
yash.rode commentedComment #8
damienmckennaAre there any security concerns about allowing people to use this to add script tags?
Comment #9
wim leers#8: Yes — just like we have those concerns for the text format + CKEditor 4.
Full HTML = "you're on your own".
That won't change.
(Unless #3097468: Deprecate the "Full HTML" text format in Standard and Umami in favor of a "content editor HTML" for content editor roles lands!)
Comment #10
wim leersPorting this to a Drupal core MR now that CKE5 has been committed…
Unfortunately @yash.rode only posted code, no commentary. So… no idea if this actually works, what his thoughts on it are. In the future, please include screenshots or at least post a comment explaining how to test it, how well it works, concerns you have, et cetera 🙏😊 This is always important, but doubly so when the issue title says to "evaluate"!
Comment #12
wim leersGot it to work locally. Next up: MR.
It does not quite do what I was expecting/hoping:
generates
… but maybe we can tweak its configuration… 🤔
Comment #14
wim leersCore MR has been created. Still more work to be done on this issue though; just like before the move to core.
Comment #15
wim leersFigured I might as well update the issue summary while I have it all in my head!
Comment #16
wim leersComment #17
wim leersClarifying issue title.
Comment #18
wim leersQuestions I will ask the CKEditor team after checking https://ckeditor.com/docs/ckeditor5/latest/features/html-embed.html:
<script>tags in this?<script>tags are apparently never executed anyway? So e.g. embedded tweets would not work anyway?Comment #19
wim leers@Reinmar said in the CKEditor 5 meeting just now:
- no technical reason why
- but we also considered using the HTML Embed plugin to make
- GHS approach is definitely simpler, but we think we may want to add something like HTML Embed-ify-
- will prioritize
@lauriii and I +1'd point 3 — we agree this would massively improve usability. That means this issue is postponed until is done. Then this will be a usability improvement. Hence recategorizing as and tagging . This is assuming the late January release will add<script>tags need to be stripped in GHS, it was just not a high enough priority.<script>tags discoverable/visible.-tags eventually anyway.
<script>tag support in GHS for the end-of-January release.<script>tag support to GHS. Clarified that in the title.Comment #21
wim leersDefinitely needs issue summary update. Will do that.
Upstream implementation plan at https://github.com/ckeditor/ckeditor5/issues/10891
Comment #22
wim leersReported again in #3256566: [upstream] <style> tag support in GHS.
Comment #23
wim leersDiscussed in CKE5 meeting: https://docs.google.com/document/d/1R0WI9eKt7vug79HrlEwI5BHfmdTgM1KJrjB6...
Fix has been merged two days ago: https://github.com/ckeditor/ckeditor5/commit/277a5919870e69c330337f13a7d....
@lauriii will create a CKE5 build of that specific commit, to allow us to test this prior to the January 26 release that they've planned.
(I will definitely still update the issue summary, unless @lauriii beats me to it.)
Comment #24
lauriiiUpdated documentation to include instructions for how to test upstream features before they are released: https://www.drupal.org/docs/core-modules-and-themes/core-modules/ckedito... .
Using those instructions, generated this patch.
I noticed bug with the upstream change and reported it on the PR: https://github.com/ckeditor/ckeditor5/pull/11075. Before posting this comment, @Reinmar mentioned that it was fixed earlier today 🎉.Comment #25
lauriiiComment #26
wim leers@lauriii So … that means that we can confirm that the upstream fix is effective, right?
If so, I think we can mark this and wait for the January 26 release of CKEditor 5; we don't need to commit a custom build (i.e. not an actual official CKEditor 5 release) to Drupal core IMHO. Do you agree?
(In the mean time, we should still update the issue summary though.)
Comment #27
lauriiiYes, I think we should mark this as postponed and wait for the release. Just wanted to keep this open for a while more in case anyone else had any additional feedback.
Comment #28
wim leers👍
Issue summary (finally) updated.
Now all we need to do here is wait for that new release :)
Comment #29
wim leers#3261600: Update to CKEditor5 v32.0.0 should unblock this! :)
Comment #30
wim leers#3261600: Update to CKEditor5 v32.0.0 landed, which means this is also fixed!