Repository navigation
Closed
Description
| BPO | 41989 |
|---|---|
| Nosy | @terryjreedy, @ezio-melotti, @waylan |
| PRs | |
| Files |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = 'https://github.com/ezio-melotti'
closed_at = None
created_at = <Date 2020-10-10.01:08:29.514>
labels = ['type-bug', 'library', '3.10']
title = 'htmlparser unclosed script tag causes data loss'
updated_at = <Date 2020-10-16.20:42:44.634>
user = 'https://github.com/waylan'bugs.python.org fields:
activity = <Date 2020-10-16.20:42:44.634>
actor = 'terry.reedy'
assignee = 'ezio.melotti'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2020-10-10.01:08:29.514>
creator = 'waylan'
dependencies = []
files = ['49505']
hgrepos = []
issue_num = 41989
keywords = ['patch']
message_count = 2.0
messages = ['378359', '378748']
nosy_count = 3.0
nosy_names = ['terry.reedy', 'ezio.melotti', 'waylan']
pr_nums = ['22658']
priority = 'normal'
resolution = None
stage = 'patch review'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue41989'
versions = ['Python 3.10']Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Activity
waylan commentedon Oct 10, 2020
When the
closemethod of the HtmlParser is called, any cached text data is generally flushed and passed to adataevent; except when indata_mode. Specifically, if an unclosedscriptorstyletag has been encountered, a call toclosedoes not flush the data.A simple test which demonstrates the issue is attached.
I see that in Lib/html/parser.py#L244-L249 there are two nested if statements which both check for
not self.cdata_elem. Obviously, if we got past the first one, that situation will never exist for the nested one. Somehow this block of code needs a branch for whenself.cdata_elemis True.I should note that the input is invalid HTML. However, the existing behavior results in data loss. Within any other unclosed tag (other than
scriptorstyle) any data is still flushed and passed to adataevent. I would expect the same behavior here. Although, the data escaping behavior should perhaps be applied as it is with data within properly closed tags.18 remaining items
[3.13] gh-86155: Fix data loss after unclosed script or style tag in …
[3.14] gh-86155: Fix data loss after unclosed script or style tag in …
[3.12] pythongh-135661: Fix parsing start and end tags in HTMLParser …
[3.12] gh-135661: Fix parsing start and end tags in HTMLParser accord…
[3.12] pythongh-135661: Fix parsing start and end tags in HTMLParser …
[3.12] pythongh-135661: Fix parsing start and end tags in HTMLParser …
[3.12] pythongh-135661: Fix parsing start and end tags in HTMLParser …
[3.11] gh-135661: Fix parsing start and end tags in HTMLParser accord…
[3.10] gh-135661: Fix parsing start and end tags in HTMLParser accord…
[3.9] gh-135661: Fix parsing start and end tags in HTMLParser accordi…
pythongh-86155: Fix data loss after unclosed script or style tag in H…
[3.9] pythongh-135661: Fix parsing start and end tags in HTMLParser a…
pythongh-86155: Fix data loss after unclosed script or style tag in H…