Skip to content

Replace Bleach with JustHTML - #4489

Merged
mathjazz merged 2 commits into
mozilla:mainfrom
flodolo:issue4223_bleach
Sep 3, 2026
Merged

Replace Bleach with JustHTML#4489
mathjazz merged 2 commits into
mozilla:mainfrom
flodolo:issue4223_bleach

Conversation

@flodolo

@flodolo flodolo commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Fixes #4223

@flodolo
flodolo requested a review from mathjazz September 3, 2026 12:48
url = reverse("pontoon.add_comment")

payload = "<svg><script>alert(1)</script>safe"
payload = "<svg><script>alert(1)</script></svg>safe"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming that the missing </svg> was a mistake, since the test was checking that <script> is removed.

Without the closing tag, safe is considered part of svg and stripped.

sanitize=False,
transforms=[
Linkify(),
Unwrap('a[href^="mailto:"]'),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is added in a separate commit.

Unlike Bleach, JustHTML linkifies email addresses, and there is no flag to prevent that. This removes all mailto links, including those added by the user. Feels like something that we should be OK doing.

@mathjazz mathjazz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@mathjazz
mathjazz merged commit 48735be into mozilla:main Sep 3, 2026
12 checks passed
@flodolo
flodolo deleted the issue4223_bleach branch September 3, 2026 15:14
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.

Switch to Bleach alternative

2 participants