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