From f2b7954ce0b07cceebea30d7a89d8a97d206d745 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Sun, 17 Aug 2025 12:59:24 +0200 Subject: [PATCH] [3.13] gh-135661: Fix parsing unterminated bogus comments in HTMLParser (GH-137873) (GH-137875) Bogus comments that start with " --- Lib/html/parser.py | 22 ++++++++-------------- Lib/test/test_htmlparser.py | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Lib/html/parser.py b/Lib/html/parser.py index 75bf8adae6d7..5d7050dad239 100644 --- a/Lib/html/parser.py +++ b/Lib/html/parser.py @@ -271,11 +271,8 @@ class HTMLParser(_markupbase.ParserBase): j -= len(suffix) break self.handle_comment(rawdata[i+4:j]) - elif startswith("', i+9) - if j < 0: - return -1 - self.unknown_decl(rawdata[i+3: j]) - return j + 3 - else: - return self.parse_bogus_comment(i) + elif rawdata[i:i+9] == '', i+9) + if j < 0: + return -1 + self.unknown_decl(rawdata[i+3: j]) + return j + 3 elif rawdata[i:i+9].lower() == ' gtpos = rawdata.find('>', i+9) diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py index fff41dab321a..6a1d69335a06 100644 --- a/Lib/test/test_htmlparser.py +++ b/Lib/test/test_htmlparser.py @@ -791,7 +791,7 @@ text self._run_check('