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 parsing "meta" tag with encoding attribute #432

Merged
merged 1 commit into from Jan 8, 2019
Merged

Fix parsing "meta" tag with encoding attribute #432

merged 1 commit into from Jan 8, 2019

Conversation

willkg
Copy link
Member

@willkg willkg commented Jan 8, 2019

When parsing a tag, the parser calls charEncoding
and changeEncoding in the input stream, but the InputStreamWithMemory
wrapper didn't have those methods. This fixes that.

This also creates a new test set for BleachHTMLParser functionality.

Fixes #431

When parsing a <meta encoding=""> tag, the parser calls charEncoding
and changeEncoding in the input stream, but the InputStreamWithMemory
wrapper didn't have those methods. This fixes that.

This also creates a new test set for BleachHTMLParser functionality.

Fixes #431
@@ -1,7 +1,7 @@
Bleach changes
==============

Version 3.0.3 (In development)
Version 3.1.0 (In development)
Copy link
Member Author

Choose a reason for hiding this comment

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

We're adding backwards-compatible API changes, so this needs to be a MINOR increment rather than a PATCH increment.

@@ -25,6 +25,12 @@ None
* Fix cases where attribute names could have invalid characters in them.
(#419)

* Fix problems with ``LinkifyFilter`` not being able to match links
across ``&amp;``. (#422)
Copy link
Member Author

Choose a reason for hiding this comment

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

I should have added this in the last PR.

@@ -80,3 +80,65 @@ def test_serializer(data, expected):
serialized = serializer.render(walker(dom))

assert serialized == expected


@pytest.mark.parametrize('parser_args, data, expected', [
Copy link
Member Author

Choose a reason for hiding this comment

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

This tests the specific issue here plus other interesting BleachHTMLParser behavior.

{},
'<a href=\'http://example.com\'\'>',
'<a href="http://example.com"></a>'
)
Copy link
Member Author

Choose a reason for hiding this comment

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

We had a LinkifyFilter test that tested this. I nixed that test and moved the relevant parts here where they're not encumbered by LinkifyFilter things.

'<a href="http://example.com/" rel="nofollow"></a>'
)


Copy link
Member Author

Choose a reason for hiding this comment

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

The important part of this got moved to the BleachHTMLParser tests.

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

@willkg willkg merged commit cabd665 into mozilla:master Jan 8, 2019
@willkg
Copy link
Member Author

willkg commented Jan 8, 2019

Thank you!

@willkg willkg deleted the 431-charencoding branch January 8, 2019 17:00
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.

AttributeError: 'InputStreamWithMemory' object has no attribute 'charEncoding'
2 participants