Skip to content

Commit ebf8ce3

Browse files
Apply suggestions from code review
Co-authored-by: Ezio Melotti <[email protected]>
1 parent 182b16f commit ebf8ce3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Lib/html/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ def parse_endtag(self, i):
401401
return -1
402402
if not endtagopen.match(rawdata, i): # </ + letter
403403
# w3.org/TR/html5/tokenization.html#end-tag-open-state
404-
if rawdata[i+2:i+3] == '>':
404+
if rawdata[i+2:i+3] == '>': # </> is ignored
405405
return i+3
406406
else:
407407
return self.parse_bogus_comment(i)

Misc/NEWS.d/next/Library/2025-06-25-14-13-39.gh-issue-135661.idjQ0B.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Fix parsing start and end tags in :class:`html.parser.HTMLParser`.
1+
Fix parsing start and end tags in :class:`html.parser.HTMLParser`
2+
according to the HTML5 standard.
23

34
* Whitespaces no longer accepted between ``</`` and the tag name.
45
E.g. ``</ script>`` does not end the script section.
@@ -8,8 +9,9 @@ Fix parsing start and end tags in :class:`html.parser.HTMLParser`.
89

910
* Null character (U+0000) no longer ends the tag name.
1011

11-
* End tag can have attributes and slashes after tag name. It no longer ends
12-
after the first ``>`` in quoted attribute value. E.g. ``</script/foo=">"/>``.
12+
* Attributes and slashes after the tag name in end tags are now correctly
13+
parsed as comments, instead of terminating after the first ``>``
14+
in quoted attribute value. E.g. ``</script/foo=">"/>``.
1315

1416
* Multiple slashes and whitespaces between the last attribute and closing ``>``
1517
are now accepted in both start and end tags. E.g. ``<a foo=bar/ //>``.

0 commit comments

Comments
 (0)