mirror of
https://github.com/python/cpython.git
synced 2024-11-26 19:34:19 +08:00
Issue #19815: Fix segfault when parsing empty namespace declaration.
Based on patches by Christian Heimes and Vajrasky Kok
This commit is contained in:
parent
c303cfdb8a
commit
5dd40e555b
@ -535,6 +535,11 @@ class ElementTreeTest(unittest.TestCase):
|
||||
('end-ns', None),
|
||||
])
|
||||
|
||||
events = ('start-ns', 'end-ns')
|
||||
context = iterparse(io.StringIO(r"<root xmlns=''/>"), events)
|
||||
res = [action for action, elem in context]
|
||||
self.assertEqual(res, ['start-ns', 'end-ns'])
|
||||
|
||||
events = ("start", "end", "bogus")
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
with open(SIMPLE_XMLFILE, "rb") as f:
|
||||
|
@ -2997,7 +2997,10 @@ expat_start_ns_handler(XMLParserObject* self, const XML_Char* prefix,
|
||||
PyObject* sprefix = NULL;
|
||||
PyObject* suri = NULL;
|
||||
|
||||
suri = PyUnicode_DecodeUTF8(uri, strlen(uri), "strict");
|
||||
if (uri)
|
||||
suri = PyUnicode_DecodeUTF8(uri, strlen(uri), "strict");
|
||||
else
|
||||
suri = PyUnicode_FromString("");
|
||||
if (!suri)
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user