Merged
Conversation
d83105f to
5b4fb68
Compare
willkg
commented
Mar 17, 2026
bleach/html5lib_shim.py
Outdated
| and " " in token["data"] | ||
| ): | ||
| # token["data"] may contain something that looks like the | ||
| # beginning of a tag, but isn't followed by an actual tag. |
Member
Author
There was a problem hiding this comment.
This isn't clear. Need to make this clearer.
willkg
commented
Mar 17, 2026
bleach/html5lib_shim.py
Outdated
| # if so, we want to reparse the tag, so we shove it back | ||
| # into the stream | ||
| head, rest = token["data"].split(" ", 1) | ||
| if rest.startswith("<"): |
Member
Author
There was a problem hiding this comment.
This won't handle the case <foo <b>text</b>.
5b4fb68 to
5cb5c9f
Compare
b70b9c0 to
29231f1
Compare
This handles the case where there's a `<` followed by one or more character such that it looks like the beginning of a start tag and then a space and then a thing that actually is a start tag. Something like: ``` <tag <b>text</b> ``` This fixes it by identifying the situation and then shoving everything after the space back into the character stream to get parsed again.
29231f1 to
0c2616d
Compare
willkg
commented
Mar 17, 2026
| last_error_token["data"] | ||
| in ( | ||
| "invalid-character-in-attribute-name", | ||
| "invalid-character-after-attribute-name", |
Member
Author
There was a problem hiding this comment.
This handles both the <foo <b>text</b> (invalid-character-in-attribute-name) and <foo <bar <b>text</b> (both an invalid-character-in-attribute-name and invalid-character-after-attribute-name errors) cases.
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.
This handles the case where there's a
<followed by one or more character such that it looks like the beginning of a start tag and then a space and then a thing that actually is a start tag. Something like:This fixes it by identifying the situation and then shoving everything after the space back into the character stream to get parsed again.
Fixes #733.