[Shop] Stop decoding entities in rendered content elements output - #203
Open
JustMordeckai wants to merge 1 commit into
Open
[Shop] Stop decoding entities in rendered content elements output#203JustMordeckai wants to merge 1 commit into
JustMordeckai wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ContentElementRendererStrategyranhtml_entity_decode(ENT_QUOTES)over the rendered HTML of every content element. The decode compensated Twig's auto-escaping for the four elements that emit pre-rendered HTML through a plain{{ variable }}, but it also inverted the escaping of every plain-text field (markup typed in a heading landed unescaped in the page) and corrupted attributes legitimately carrying entities (data-live-props-value="{"...gets cut at the first decoded quote, killing Symfony UX Live Components inside products grids). Details and reproduction in #202.This PR makes the strategy emit the rendered HTML untouched, and moves the unescaping where it belongs: a local
|rawin the four templates whose variable holds pre-rendered HTML (textarea,single_media,multiple_media,pages_collection). For those four elements the output is unchanged: their escape-then-decode round trip was lossless,|rawjust short-circuits it. Every other element now keeps Twig's escaping. Content that relied on the accidental unescaping (raw HTML typed into plain-text fields such as headings) now displays literally, which is the escaping contract those fields were meant to have.Tests: the two strategy tests that asserted the decoding are updated, and a new one pins the pass-through behaviour (escaped user text stays escaped, entity-carrying attributes survive). Full
tests/Unitsuite green (183 tests, 457 assertions).Deliberately out of scope:
Twig/Runtime/RenderContentRuntimeapplies the same decode, but to stored content rather than template output, so it deserves its own analysis. Happy to follow up on it separately.