You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HTMLParser does not support escapable raw text mode (<textarea> and <title>) #118350
Isn't this because you didn't close your <style> tag? If I remember correctly style tags go on until </style> is seen regardless of any other tag-like text within the tag, because they may contain text in other languages.
@JelleZijlstra , indeed! Closing <style> allows the snippet to be parsed. However, isn't it inconsistent with the the behaviour observed when parsing other tags?
For example, this broken HTML is parsed correctly:
<head><title>Rebelious<h1>Heading<ahref="https://example.net">example.net
<span>not<ahref="https://www.arpa.home">arpa.home<p>Paragraph<h2>and more
However I believe your HTML with <title>Rebelious<h1> . . . does trigger a bug. The <title> element is supposed to be an “escapable raw text element”, so <h1> should be counted as part of the raw title text. However it gets parsed as a tag:
Encountered a start tag: title
Encountered some data : Rebelious
Encountered a start tag: h1
changed the title [-]HTMLParser stops parsing upon encountering `<style>` tag[/-][+]HTMLParser does not support escapable raw text mode (<textarea> and <title>)[/+]on Jul 14, 2025
Activity
JelleZijlstra commentedon Apr 27, 2024
Isn't this because you didn't close your
<style>tag? If I remember correctly style tags go on until</style>is seen regardless of any other tag-like text within the tag, because they may contain text in other languages.savchenko commentedon Apr 28, 2024
@JelleZijlstra , indeed! Closing
<style>allows the snippet to be parsed. However, isn't it inconsistent with the the behaviour observed when parsing other tags?For example, this broken HTML is parsed correctly:
vadmium commentedon Apr 28, 2024
The difference is that <style> is a “raw text element”. It cannot contain HTML markup. Most other tags can be followed by other markup. See https://html.spec.whatwg.org/multipage/syntax.html#raw-text-elements
However I believe your HTML with
<title>Rebelious<h1> . . .does trigger a bug. The <title> element is supposed to be an “escapable raw text element”, so<h1>should be counted as part of the raw title text. However it gets parsed as a tag:Encountered a start tag: title
Encountered some data : Rebelious
Encountered a start tag: h1
serhiy-storchaka commentedon May 7, 2025
The original issue (about unclosed
<style>) looks like a duplicate of #86155.[-]HTMLParser stops parsing upon encountering `<style>` tag[/-][+]HTMLParser does not support escapable raw text mode (<textarea> and <title>)[/+]11 remaining items
pythongh-118350: Fix support of elements "textarea" and "title" in HT…
[3.11] pythongh-118350: Fix support of elements "textarea" and "title…
[3.10] pythongh-118350: Fix support of elements "textarea" and "title…
[3.9] pythongh-118350: Fix support of elements "textarea" and "title"…
pythongh-118350: Fix support of elements "textarea" and "title" in HT…
[3.14] pythongh-118350: Fix support of elements "textarea" and "title…
[3.9] gh-118350: Fix support of elements "textarea" and "title" in HT…
[3.11] gh-118350: Fix support of elements "textarea" and "title" in H…
[3.10] gh-118350: Fix support of elements "textarea" and "title" in H…
[html.parser] Fix stubtest for later patch releases
Fix raw markup inside <title> on Python 3.11.14
ui_test: fix HTML structure in testFolderWorkflowActionWithoutConfirm…