]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-135661: Fix CDATA section parsing in HTMLParser (GH-135665)
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 14 Aug 2025 18:13:22 +0000 (21:13 +0300)
committerGitHub <noreply@github.com>
Thu, 14 Aug 2025 18:13:22 +0000 (18:13 +0000)
commit0cbbfc462119b9107b373c24d2bda5a1271bed36
tree6063e0e35fbdb2be62768e9a5ce104f01a470d0d
parent04f8ef663be7589def9f456a2024e1707e3408ea
gh-135661: Fix CDATA section parsing in HTMLParser (GH-135665)

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