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

fix stripping block-level tags (#369) #651

Merged
merged 6 commits into from Apr 7, 2022
Merged

fix stripping block-level tags (#369) #651

merged 6 commits into from Apr 7, 2022

Conversation

willkg
Copy link
Member

@willkg willkg commented Apr 4, 2022

When Bleach strips a block-level element, it should replace it with a newline preserving the whitespace that would exist if it was being parsed by a browser.

Fixes #369.

This supersedes PR #642.

jvanasco and others added 4 commits April 4, 2022 11:29
(From original commit)

block elements are tracked and a newline is inserted when they are stripped.

new tests are included.

See Issue #369

This is a simplified rewrite of #461 against the current main
@willkg willkg requested a review from g-k April 4, 2022 19:14
This adds comments for what we're doing and why.
@willkg
Copy link
Member Author

willkg commented Apr 4, 2022

@g-k Can you eyeball this? I'm pretty sure it's fine.

Copy link
Collaborator

@g-k g-k left a comment

Choose a reason for hiding this comment

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

r+ lgtm

"This is our description! &\nnice!",
),
(
# double-wrap causes an initial newline--this can"t really be
Copy link
Collaborator

Choose a reason for hiding this comment

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

extra nitty nit: the apostrophe is rendering with a double quote in can"t

@Alex3917
Copy link

Alex3917 commented Apr 5, 2022

Does it make sense to make this optional? (Other than via monkey patching HTML_TAGS_BLOCK_LEVEL.)

@willkg
Copy link
Member Author

willkg commented Apr 5, 2022

Does it make sense to make this optional? (Other than via monkey patching HTML_TAGS_BLOCK_LEVEL.)

I'm going to evaluate "does it make sense" in terms of "users have expressed a need" and so far I haven't seen anyone express a need to make this optional. In my uses of Bleach, having the additional newlines would have been fine. Given that, I think the answer at this time should be no. If someone has a need, they can write up an issue and we can evaluate things from there.

@willkg willkg merged commit a14d412 into mozilla:main Apr 7, 2022
@willkg willkg deleted the 369-whitespace branch April 7, 2022 14:53
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.

[Accessibility bug] Semantic whitespace implied by block elements isn't retained properly
4 participants