2024-02-15 15:36:25 +01:00
|
|
|
From f2eebf3c38eae77765247791576b437ec25ccfe2 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
Date: Sun, 11 Feb 2024 12:08:39 +0200
|
|
|
|
Subject: [PATCH] gh-115133: Fix tests for XMLPullParser with Expat 2.6.0
|
|
|
|
(GH-115164)
|
|
|
|
|
|
|
|
Feeding the parser by too small chunks defers parsing to prevent
|
|
|
|
CVE-2023-52425. Future versions of Expat may be more reactive.
|
|
|
|
(cherry picked from commit 4a08e7b3431cd32a0daf22a33421cd3035343dc4)
|
|
|
|
|
|
|
|
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
---
|
2024-03-21 17:45:30 +01:00
|
|
|
Lib/test/test_xml_etree.py | 6 ++++++
|
|
|
|
Misc/NEWS.d/next/Library/2024-02-08-14-21-28.gh-issue-115133.ycl4ko.rst | 2 ++
|
|
|
|
2 files changed, 8 insertions(+)
|
2024-02-15 15:36:25 +01:00
|
|
|
create mode 100644 Misc/NEWS.d/next/Library/2024-02-08-14-21-28.gh-issue-115133.ycl4ko.rst
|
|
|
|
|
2024-03-21 17:45:30 +01:00
|
|
|
--- a/Lib/test/test_xml_etree.py
|
|
|
|
+++ b/Lib/test/test_xml_etree.py
|
|
|
|
@@ -121,6 +121,10 @@ ATTLIST_XML = """\
|
2024-02-15 15:36:25 +01:00
|
|
|
</foo>
|
|
|
|
"""
|
|
|
|
|
|
|
|
+fails_with_expat_2_6_0 = (unittest.expectedFailure
|
|
|
|
+ if pyexpat.version_info >= (2, 6, 0) else
|
|
|
|
+ lambda test: test)
|
|
|
|
+
|
|
|
|
def checkwarnings(*filters, quiet=False):
|
|
|
|
def decorator(test):
|
|
|
|
def newtest(*args, **kwargs):
|
2024-03-21 17:45:30 +01:00
|
|
|
@@ -1420,9 +1424,11 @@ class XMLPullParserTest(unittest.TestCas
|
|
|
|
self.assert_event_tags(parser, [('end', 'root')])
|
|
|
|
self.assertIsNone(parser.close())
|
2024-02-15 15:36:25 +01:00
|
|
|
|
|
|
|
+ @fails_with_expat_2_6_0
|
2024-03-21 17:45:30 +01:00
|
|
|
def test_simple_xml_chunk_1(self):
|
|
|
|
self.test_simple_xml(chunk_size=1, flush=True)
|
|
|
|
|
2024-02-15 15:36:25 +01:00
|
|
|
+ @fails_with_expat_2_6_0
|
2024-03-21 17:45:30 +01:00
|
|
|
def test_simple_xml_chunk_5(self):
|
|
|
|
self.test_simple_xml(chunk_size=5, flush=True)
|
2024-02-15 15:36:25 +01:00
|
|
|
|
|
|
|
--- /dev/null
|
2024-03-21 17:45:30 +01:00
|
|
|
+++ b/Misc/NEWS.d/next/Library/2024-02-08-14-21-28.gh-issue-115133.ycl4ko.rst
|
2024-02-15 15:36:25 +01:00
|
|
|
@@ -0,0 +1,2 @@
|
|
|
|
+Fix tests for :class:`~xml.etree.ElementTree.XMLPullParser` with Expat
|
|
|
|
+2.6.0.
|