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: escape foreign style tag content when serializing HTML5 (v1.15.x) #3350

Merged
merged 2 commits into from
Dec 2, 2024

Conversation

flavorjones
Copy link
Member

Backport of #3348 to v1.15.x

Normally, a `style` tag is considered to be a raw text element,
meaning `<` is parsed as part of a possible "tag start" token, and is
serialized literally (and not rendered as an escaped character
reference `&lt;`).

However, when appearing in either SVG or MathML foreign content, a
`style` tag should *not* be considered a raw text element, and should
be escaped when serialized. libgumbo is parsing this case correctly,
but our HTML5 serialization code does not escape the content.

This commit updates the static `is_one_of()` C function to consider
the namespace of the parent node as well as the tag's local name when
deciding whether the tag matches the list of HTML elements, so that a
`style` tag in foreign content will *not* match, but a `style` tag in
HTML content will match.

(cherry picked from commit 2f4adec68345094760a8ba487360757f5038e9c3)
@flavorjones flavorjones added the backport Backport of a PR to the current release branch label Dec 1, 2024
@flavorjones flavorjones merged commit 9acd02d into v1.15.x Dec 2, 2024
91 of 103 checks passed
@flavorjones flavorjones deleted the flavorjones-svg-style-serialization_1.15 branch December 2, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Backport of a PR to the current release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant