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