Port over of WT-1217 from Springfield: Drop HTML comments from sanitized output#17183
Merged
Conversation
…zed output Since switching from bleach to justhtml (WT-578), HTML comments in Markdown sources may have been surfaced on the page as literal `<!-- ... -->` text because the markup was HTML escaped. With the setting on `disallowed_tag_handling="escape"`, justhtml's escape pass wins over its DropComments transform, and using an explicit Sanitize() to force ordering discards our custom policy. This issue was visible on release-notes pages on www.firefox.com and we're making the same change here for consistency. The fix is to strip `<!--...-->` with a regex before handing the HTML to justhtml. This keeps the escape behaviour for unknown tags so example markup still renders as visible source.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #17183 +/- ##
=======================================
Coverage 82.33% 82.34%
=======================================
Files 181 181
Lines 9705 9709 +4
=======================================
+ Hits 7991 7995 +4
Misses 1714 1714 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Since switching from bleach to justhtml (WT-578), HTML comments in Markdown sources may have been surfaced on the page as literal
<!-- ... -->text because the markup was HTML escaped. With the setting ondisallowed_tag_handling="escape", justhtml's escape pass wins over its DropComments transform, and using an explicit Sanitize() to force ordering discards our custom policy.This issue was visible on release-notes pages on www.firefox.com and we're making the same change here for consistency.
The fix is to strip
<!--...-->with a regex before handing the HTML to justhtml. This keeps the escape behaviour for unknown tags so example markup still renders as visible source.Original PR mozmeao/springfield#1369