Blame SOURCES/00378-support-expat-2-4-5.patch

96031f
From a5b78c6f1c802f6023bd4d7a248dc83be1eef6a3 Mon Sep 17 00:00:00 2001
96031f
From: Sebastian Pipping <sebastian@pipping.org>
96031f
Date: Mon, 21 Feb 2022 15:48:32 +0100
96031f
Subject: [PATCH] 00378: Support expat 2.4.5
96031f
96031f
Curly brackets were never allowed in namespace URIs
96031f
according to RFC 3986, and so-called namespace-validating
96031f
XML parsers have the right to reject them a invalid URIs.
96031f
96031f
libexpat >=2.4.5 has become strcter in that regard due to
96031f
related security issues; with ET.XML instantiating a
96031f
namespace-aware parser under the hood, this test has no
96031f
future in CPython.
96031f
96031f
References:
96031f
- https://datatracker.ietf.org/doc/html/rfc3968
96031f
- https://www.w3.org/TR/xml-names/
96031f
96031f
Also, test_minidom.py: Support Expat >=2.4.5
96031f
96031f
Upstream: https://bugs.python.org/issue46811
96031f
96031f
Co-authored-by: Sebastian Pipping <sebastian@pipping.org>
96031f
---
96031f
 Lib/test/test_minidom.py                             | 12 +++++++++---
96031f
 Lib/test/test_xml_etree.py                           |  6 ------
96031f
 .../Library/2022-02-20-21-03-31.bpo-46811.8BxgdQ.rst |  1 +
96031f
 3 files changed, 10 insertions(+), 9 deletions(-)
96031f
 create mode 100644 Misc/NEWS.d/next/Library/2022-02-20-21-03-31.bpo-46811.8BxgdQ.rst
96031f
96031f
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
96031f
index d55e25e..e947382 100644
96031f
--- a/Lib/test/test_minidom.py
96031f
+++ b/Lib/test/test_minidom.py
96031f
@@ -5,10 +5,12 @@ import pickle
96031f
 from test import support
96031f
 import unittest
96031f
 
96031f
+import pyexpat
96031f
 import xml.dom.minidom
96031f
 
96031f
 from xml.dom.minidom import parse, Node, Document, parseString
96031f
 from xml.dom.minidom import getDOMImplementation
96031f
+from xml.parsers.expat import ExpatError
96031f
 
96031f
 
96031f
 tstfile = support.findfile("test.xml", subdir="xmltestdata")
96031f
@@ -1156,8 +1158,10 @@ class MinidomTest(unittest.TestCase):
96031f
 
96031f
         # Verify that character decoding errors raise exceptions instead
96031f
         # of crashing
96031f
-        self.assertRaises(UnicodeDecodeError, parseString,
96031f
-                b'<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>')
96031f
+        self.assertRaises(ExpatError, parseString,
96031f
+                b'<fran\xe7ais></fran\xe7ais>')
96031f
+        self.assertRaises(ExpatError, parseString,
96031f
+                b'<franais>Comment \xe7a va ? Tr\xe8s bien ?</franais>')
96031f
 
96031f
         doc.unlink()
96031f
 
96031f
@@ -1602,7 +1606,9 @@ class MinidomTest(unittest.TestCase):
96031f
         self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE)
96031f
 
96031f
     def testExceptionOnSpacesInXMLNSValue(self):
96031f
-        with self.assertRaisesRegex(ValueError, 'Unsupported syntax'):
96031f
+        context = self.assertRaisesRegex(ExpatError, 'syntax error')
96031f
+
96031f
+        with context:
96031f
             parseString('<element xmlns:abc="http:abc.com/de f g/hi/j k"><abc:foo /></element>')
96031f
 
96031f
     def testDocRemoveChild(self):
96031f
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
96031f
index b01709e..acaa519 100644
96031f
--- a/Lib/test/test_xml_etree.py
96031f
+++ b/Lib/test/test_xml_etree.py
96031f
@@ -1668,12 +1668,6 @@ class BugsTest(unittest.TestCase):
96031f
                 b"\n"
96031f
                 b'<body>tãg</body>')
96031f
 
96031f
-    def test_issue3151(self):
96031f
-        e = ET.XML('<prefix:localname xmlns:prefix="${stuff}"/>')
96031f
-        self.assertEqual(e.tag, '{${stuff}}localname')
96031f
-        t = ET.ElementTree(e)
96031f
-        self.assertEqual(ET.tostring(e), b'<ns0:localname xmlns:ns0="${stuff}" />')
96031f
-
96031f
     def test_issue6565(self):
96031f
         elem = ET.XML("<body><tag/></body>")
96031f
         self.assertEqual(summarize_list(elem), ['tag'])
96031f
diff --git a/Misc/NEWS.d/next/Library/2022-02-20-21-03-31.bpo-46811.8BxgdQ.rst b/Misc/NEWS.d/next/Library/2022-02-20-21-03-31.bpo-46811.8BxgdQ.rst
96031f
new file mode 100644
96031f
index 0000000..6969bd1
96031f
--- /dev/null
96031f
+++ b/Misc/NEWS.d/next/Library/2022-02-20-21-03-31.bpo-46811.8BxgdQ.rst
96031f
@@ -0,0 +1 @@
96031f
+Make test suite support Expat >=2.4.5
96031f
-- 
96031f
2.35.1
96031f