From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sun, 17 Aug 2025 10:59:24 +0000 (+0200) Subject: [3.13] gh-135661: Fix parsing unterminated bogus comments in HTMLParser (GH-137873... X-Git-Tag: v3.13.8~179 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f2b7954ce0b07cceebea30d7a89d8a97d206d745;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-135661: Fix parsing unterminated bogus comments in HTMLParser (GH-137873) (GH-137875) Bogus comments that start with " --- 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('