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

refactor: replace bleach with nh3 (ammonia) #295

Merged
merged 5 commits into from
Sep 5, 2023

Conversation

miketheman
Copy link
Member

Refs: https://nh3.readthedocs.io/

Bleach has been deprecated.

This refactor includes"

  • a non-breaking refactor of lists to sets to support both bleach and nh3
  • addition of the pytest-icdiff test helper to find the one-character changes
  • removal of the bleach code and filters
  • updates to the test suite

Notable changes in the tests:

  • all <a> tags now get rel="nofollow" added
  • less usage of escaped characters like &quot; for "

As a preparation for conversion from bleach, use sets instead of lists.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Refs: https://pypi.org/project/pytest-icdiff/

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Refs: https://nh3.readthedocs.io/

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
nh3 is both tigher on removing truly scary code, and looser on
escaping already-encapsulated quotations and control characters.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
@miketheman
Copy link
Member Author

Expecting failure for checked boolean attributes - see this issue for more.

@miketheman
Copy link
Member Author

We could update the tests here as well to allow checked to become checked="" in the meantime, if we were worried about continued use of bleach.

@di
Copy link
Member

di commented Sep 5, 2023

We could update the tests here as well to allow checked to become checked="" in the meantime, if we were worried about continued use of bleach.

I think that's probably fine. Since they're equivalent, I don't think it really matters which one ends up being used.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
@miketheman miketheman requested a review from di September 5, 2023 18:55
@miketheman miketheman merged commit e5221c2 into pypa:main Sep 5, 2023
@miketheman miketheman deleted the miketheman/refactor-to-nh3 branch September 5, 2023 20:04
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.

2 participants