Skip to content

Commit cf8e373

Browse files
committed
support libexpat patched for CVE-2022-25236
Code is based on gh#python/cpython@d4f5bb9 (released upstream in 3.7.13) Fixes: bpo#46811 Patch: support-expat-CVE-2022-25236-patched.patch
1 parent cc36ca8 commit cf8e373

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

Lib/test/test_minidom.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from xml.dom.minidom import parse, Node, Document, parseString
1111
from xml.dom.minidom import getDOMImplementation
12+
from xml.parsers.expat import ExpatError
1213

1314

1415
tstfile = support.findfile("test.xml", subdir="xmltestdata")
@@ -1156,8 +1157,12 @@ def testEncodings(self):
11561157

11571158
# Verify that character decoding errors raise exceptions instead
11581159
# of crashing
1159-
self.assertRaises(UnicodeDecodeError, parseString,
1160-
b'<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>')
1160+
# It doesn’t make any sense to insist on the exact text of the
1161+
# error message, or even the exact Exception … it is enough that
1162+
# the error has been discovered.
1163+
with self.assertRaises((UnicodeDecodeError, ExpatError)):
1164+
parseString(
1165+
b'<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>')
11611166

11621167
doc.unlink()
11631168

@@ -1602,8 +1607,11 @@ def testEmptyXMLNSValue(self):
16021607
self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE)
16031608

16041609
def testExceptionOnSpacesInXMLNSValue(self):
1605-
with self.assertRaisesRegex(ValueError, 'Unsupported syntax'):
1606-
parseString('<element xmlns:abc="http:abc.com/de f g/hi/j k"><abc:foo /></element>')
1610+
# It doesn’t make any sense to insist on the exact text of the
1611+
# error message, or even the exact Exception … it is enough that
1612+
# the error has been discovered.
1613+
with self.assertRaises((ExpatError, ValueError)):
1614+
parseString('<element xmlns:abc="http:abc.com/de f g/hi/j k"><abc:foo /></element>')
16071615

16081616
def testDocRemoveChild(self):
16091617
doc = parse(tstfile)

Lib/test/test_xml_etree.py

-6
Original file line numberDiff line numberDiff line change
@@ -1668,12 +1668,6 @@ def test_issue6233(self):
16681668
b"<?xml version='1.0' encoding='ascii'?>\n"
16691669
b'<body>t&#227;g</body>')
16701670

1671-
def test_issue3151(self):
1672-
e = ET.XML('<prefix:localname xmlns:prefix="${stuff}"/>')
1673-
self.assertEqual(e.tag, '{${stuff}}localname')
1674-
t = ET.ElementTree(e)
1675-
self.assertEqual(ET.tostring(e), b'<ns0:localname xmlns:ns0="${stuff}" />')
1676-
16771671
def test_issue6565(self):
16781672
elem = ET.XML("<body><tag/></body>")
16791673
self.assertEqual(summarize_list(elem), ['tag'])

0 commit comments

Comments
 (0)