Fix Widget saving non-XML entities to layout_update #10151
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When saving a widget containing
characters, layout merging fails.Description
When saving a widget containing
characters in the data, layout merging fails. Currently,\Magento\Widget\Model\Widget\Instance
escapes the HTML when saving the data to thelayout_update
table. That's not sufficient, because it won't prevent characters like
being added to the XML. As a side note: the supported character entities in XML are very limited.More about this topic can be found here.
By using
html_entity_decode
before escaping the HTML, there won't be incompatible character entities in the HTML when escaping it.The use case of having
in the widget fields may seem a bit extraordinary. My use case(and many other's) is having added a WYSIWYG block to a custom widget. A WYSIWYG produces quite some characters when being used.Fixed Issues
Steps to reproduce the problem
Manual testing procedure
Follow the Steps to reproduce after applying this fix.
Contribution checklist