]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.12] gh-135661: Fix CDATA section parsing in HTMLParser (GH-135665) (#137774)
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 6 Oct 2025 14:06:29 +0000 (17:06 +0300)
committerGitHub <noreply@github.com>
Mon, 6 Oct 2025 14:06:29 +0000 (16:06 +0200)
commitdcf24768c918c41821cda6fe6a1aa20ce26545dd
tree6eec163078457667c0f894e0fda2189fbc2ef885
parentade85bc5f4092723383885079742d8d4fdf74f1c
[3.12] gh-135661: Fix CDATA section parsing in HTMLParser (GH-135665) (#137774)

"] ]>" 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)
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]