Repository navigation
Fix StripHTML crash when strip_comments is disabled - #3009
Merged
facelessuser merged 2 commits intoOct 24, 2026
Merged
Conversation
run() referenced self.strip_js_on_attributes, which __init__ never sets, so any config with strip_comments: False raised AttributeError. re_attributes already covers the on* attributes, so drop the stale check. Fixes facelessuser#3008
Owner
|
Good find, thanks for the PR! @gir-bot lgtm |
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 #3008
Problem
StripHtmlPostprocessor.run()checksself.strip_js_on_attributes, which__init__never sets. Any config withstrip_comments: FalseraisesAttributeErroron every document.Change
Drop the stale attribute from the check:
strip = self.strip_comments or self.re_attributes.re_attributesis built wheneverstrip_js_on_attributesis on (it addson\w+) orstrip_attributesis non-empty, so this is what the original line meant. With everything disabled it's still a no-op. Added a changelog entry under 12.3.1.Verification
tests/test_extensions/test_striphmtl.py::TestStripHTMLKeepComments::test_keep_commentsfails before this change with theAttributeErrorand passes after.tests/test_extensions: 783 passed, no new failures.I found this with patchwork, an automated code-audit tool I run, and verified the reproduction test in an isolated sandbox. If tool-assisted reports aren't welcome here, let me know and I won't send more.