Repository navigation
fix: escape markup in inlined pseudo-element content - #707
Merged
Merged
Conversation
With inlinePseudoElements enabled, the CSS content value of ::before and ::after rules was written into the output unescaped, because juice parses with decodeEntities off and .text() is then serialized raw. Markup in content strings, attr() or var() values became live HTML. Escape < and > when the cheerio instance writes text raw, and leave text alone for instances that already escape it, to avoid double escaping. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes GHSA-pfw7-6c5v-2837.
With
inlinePseudoElements: true, the CSScontentvalue of::before/::afterrules was inserted into the output as raw HTML. Juice parses withdecodeEntities: false, so.text()is serialized unescaped, and markup incontentstrings,attr()orvar()values became live HTML:Changes
<and>in pseudo-element text when the cheerio instance writes text raw.&is left alone, so entities like keep working andattr()values aren't double-escaped.juiceDocument/inlineDocumentwith default options (which already escape) aren't double-escaped.Behavior change
Only affects
inlinePseudoElements: true. Tags inside CSScontent(e.g.content: "<br>") now render as literal text, matching how browsers treatcontent. Regular HTML in the email is untouched.Tests
Regression tests for
contentstrings,attr(),xmlMode, entity preservation, and a default cheerio instance viainlineDocument.🤖 Generated with Claude Code