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

Fix for double escaping content in nested editables #4227

Merged
merged 7 commits into from
Aug 27, 2020
Merged

Conversation

Comandeer
Copy link
Member

What is the purpose of this pull request?

Bug fix

Does your PR contain necessary tests?

All patches that change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.

This PR contains

  • Unit tests
  • Manual tests

Did you follow the CKEditor 4 code style guide?

Your code should follow the guidelines from the CKEditor 4 code style guide which helps keep the entire codebase consistent.

  • PR is consistent with the code style guide

What is the proposed changelog entry for this pull request?

* [#4060](https://github.com/ckeditor/ckeditor4/issues/4060): Fixed: content inside nested editables was escaped twice.

What changes did you make?

It seems that the content inside nested editables was changed due to the fact that it was escaped twice – once during widget initialization and second time during processing the whole editor content. The fix forces unescaping the content before the widget initialization, which eliminated the second, unnecessary escape.

Which issues does your PR resolve?

Closes #4060.

@jacekbogdanski jacekbogdanski self-assigned this Aug 26, 2020
@jacekbogdanski jacekbogdanski self-requested a review August 26, 2020 09:20
Copy link
Member

@jacekbogdanski jacekbogdanski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The testing button works incorrectly. It always gives green feedback for editing mode and red for source editing with and without widget changes.

switch

  1. Switching between editing and source mode a second time gives a bit different HTML:
    For the first switch:
<div class="testwidget"><div class="content">CKEditor rulez<br /><script src="data:text/javascript,''"></script></div></div>

For the second switch:

<div class="testwidget"><div class="content">CKEditor rulez<script src="data:text/javascript,''"></script></div></div>

Not sure if it's caused by widget definition itself, but it changes widget editable content:

widget

  1. I have been really worried about the performance impact of this change. However, it seems not that huge, a couple of ms for complex editable. Nevertheless, it would be nice to prepare some complex widget with a couple of editable elements to make sure everything works ok, WDYT?

@@ -0,0 +1,24 @@
@bender-tags: 4.15.0, bug, 4060
@bender-ui: collapsed
@bender-ckeditor-plugins: widget, wysiwygarea, toolbar, sourcearea
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding htmlwriter plugin here to make source HTML more readable?

@Comandeer
Copy link
Member Author

Comandeer commented Aug 27, 2020

The testing button works incorrectly. It always gives green feedback for editing mode and red for source editing with and without widget changes.

Actually it was intended to work only in WYSIWYG mode… But thanks to your feedback, I greatly simplified manual test – now it's basically just clicking a button 😅.

Switching between editing and source mode a second time gives a bit different HTML

Yup, it was connected with invalid widget definition. Fixed.

I have been really worried about the performance impact of this change. However, it seems not that huge, a couple of ms for complex editable. Nevertheless, it would be nice to prepare some complex widget with a couple of editable elements to make sure everything works ok, WDYT?

Added 👍

Copy link
Member

@jacekbogdanski jacekbogdanski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Embed widget nested inside another widget gets URL broken on mode change
2 participants