Skip to content

Issue while parsing valid <meta> tags #586

Open

Description

@ikus060

I'm running into issue with HTML parsing of the following HTML.

parser = html5lib.HTMLParser(strict=True)
parser.parse('<!DOCTYPE html><html lang="en"><head><title>test</title><meta http-equiv="refresh" content="1; url=http://127.0.0.1:54583/restore/admin/testcases/%3CF%21ch%C3%AFer%3E%20%28%40vec%29%20%7Bc%C3%A0ra%C3%A7t%23%C3%A8r%C3%AB%7D%20%24%C3%A9p%C3%AAcial?date=1454448640&raw=1" ></head><body>COUCOU</body></html>')

I get this exception.

html5lib.html5parser.ParseError: Named entity expected. Got none.

According to w3c validator. This is valid.

Image

Activity

  1. MaciejZet commented on Oct 25, 2026

    @MaciejZet

    Reproduced on 1.1 and master fd4f032 with etree, DOM and lxml:

    import html5lib
    
    html = ('<!doctype html><html><head><title>x</title>'
            '<meta http-equiv="refresh" content="1; url=https://example.test/?date=1&raw=1">'
            '</head><body></body></html>')
    html5lib.HTMLParser(strict=True).parse(html)
    # ParseError: Named entity expected. Got none.

    strict=False preserves the attribute value correctly, although parser.errors still records the false error. The WHATWG ambiguous ampersand state does not require an error for &raw=1; strict=True incorrectly rejects it.

    Full base/optional suites passed locally on macOS with CPython 3.8–3.12: 17,499/23,563 passes per version, retaining existing skips and xfails. Runs used setuptools 70.3.0 and chardet 5.2.0 to isolate separate dependency failures. Additional malformed-reference controls still raised as expected. No hosted test CI result was verified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ Proxy