]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] gh-135661: Fix CDATA section parsing in HTMLParser (GH-135665) (GH-137773)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 14 Aug 2025 18:44:16 +0000 (20:44 +0200)
committerGitHub <noreply@github.com>
Thu, 14 Aug 2025 18:44:16 +0000 (21:44 +0300)
commita33596765b4d1add17e8e1ffc216c126325a14a3
treea62a6a21254a56c52d5dce7ace1a10267488b003
parent46b2577b4244d1badb9475a6f3aaf6b90a237721
[3.13] gh-135661: Fix CDATA section parsing in HTMLParser (GH-135665) (GH-137773)

"] ]>" and "]] >" no longer end the CDATA section.

Make CDATA section parsing  context depending.
Add private method HTMLParser._set_support_cdata() to change the context.
If called with True, "<[CDATA[" starts a CDATA section which ends with "]]>".
If called with False, "<[CDATA[" starts a bogus comments which ends with ">".
(cherry picked from commit 0cbbfc462119b9107b373c24d2bda5a1271bed36)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/html/parser.py
Lib/test/test_htmlparser.py
Misc/NEWS.d/next/Security/2025-06-18-13-34-55.gh-issue-135661.NZlpWf.rst [new file with mode: 0644]