Skip to content

Test about badly escaped src in HTML is failing #264

@benoit74

Description

@benoit74
=================================== FAILURES ===================================
____________________ test_simple_rewrite[badly_escaped_src] ____________________

input_content = '<img src="image.png?param1=value1&param2=value2">'
expected_output = '<img src="image.png%3Fparam1%3Dvalue1&param2%3Dvalue2">'

    @pytest.mark.parametrize(
        "input_content,expected_output",
        [
            pytest.param(
                """<a type="whatever"></a>""",
                """<a type="whatever"></a>""",
                id="double_quoted_attr",
            ),
            pytest.param(
                "<a type='whatever'></a>",
                """<a type="whatever"></a>""",
                id="single_quoted_attr",
            ),
            pytest.param(
                """<a type="wha&QUOT;tever"></a>""",
                """<a type="wha&quot;tever"></a>""",
                id="uppercase_named_reference_in_attr",
            ),
            pytest.param(
                """<a type="wha&#x22;tever"></a>""",
                """<a type="wha&quot;tever"></a>""",
                id="numeric_reference_in_attr",
            ),
            pytest.param(
                """<a type="wha&#198;tever"></a>""",
                """<a type="whaÆtever"></a>""",
                id="numeric_reference_in_attr",
            ),
            pytest.param(
                """<img src="image.png?param1=value1&param2=value2">""",
                """<img src="image.png%3Fparam1%3Dvalue1&param2%3Dvalue2">""",
                id="badly_escaped_src",
            ),
        ],
    )
    def test_simple_rewrite(input_content: str, expected_output: str):
>       assert (
            HtmlRewriter(
                ArticleUrlRewriter(article_url=HttpUrl("http://example.com/")),
                None,
                None,
                None,
            )
            .rewrite(input_content)
            .content
            == expected_output
        )
E       assert '<img src="image.png%3Fparam1%3Dvalue1%26param2%3Dvalue2">' == '<img src="image.png%3Fparam1%3Dvalue1&param2%3Dvalue2">'
E         
E         - <img src="image.png%3Fparam1%3Dvalue1&param2%3Dvalue2">
E         ?                                      ^
E         + <img src="image.png%3Fparam1%3Dvalue1%26param2%3Dvalue2">
E         ?                                      ^^^

tests/rewriting/test_html_rewriting.py:798: AssertionError

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions