Skip to content

[Shop] Stop decoding entities in rendered content elements output - #203

Open
JustMordeckai wants to merge 1 commit into
Sylius:1.1from
JustMordeckai:fix/202-content-element-entity-decode
Open

[Shop] Stop decoding entities in rendered content elements output#203
JustMordeckai wants to merge 1 commit into
Sylius:1.1from
JustMordeckai:fix/202-content-element-entity-decode

Conversation

@JustMordeckai

Copy link
Copy Markdown
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets fixes #202
License MIT

ContentElementRendererStrategy ran html_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 |raw in 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, |raw just 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/Unit suite green (183 tests, 457 assertions).

Deliberately out of scope: Twig/Runtime/RenderContentRuntime applies the same decode, but to stored content rather than template output, so it deserves its own analysis. Happy to follow up on it separately.

@JustMordeckai
JustMordeckai requested a review from a team as a code owner August 3, 2026 14:24
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.

1 participant