From: Raymond Hettinger Date: Sun, 15 Jun 2014 21:48:19 +0000 (-0700) Subject: Issue #21774: Fix incorrect variable in xml.dom.minidom X-Git-Tag: v3.4.2rc1~388 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=92a405534383927c48c8de2fc6bf06127ef2be78;p=python Issue #21774: Fix incorrect variable in xml.dom.minidom --- diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index 5ab4bfe1a4..2489ff7649 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -1531,6 +1531,13 @@ class MinidomTest(unittest.TestCase): num_children_after = len(doc.childNodes) self.assertTrue(num_children_after == num_children_before - 1) + def testProcessingInstructionNameError(self): + # wrong variable in .nodeValue property will + # lead to "NameError: name 'data' is not defined" + doc = parse(tstfile) + pi = doc.createProcessingInstruction("y", "z") + pi.nodeValue = "crash" + def test_main(): run_unittest(MinidomTest) diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 6f71631464..c379a332e1 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -976,7 +976,7 @@ class ProcessingInstruction(Childless, Node): def _get_nodeValue(self): return self.data def _set_nodeValue(self, value): - self.data = data + self.data = value nodeValue = property(_get_nodeValue, _set_nodeValue) # nodeName is an alias for target diff --git a/Misc/NEWS b/Misc/NEWS index 66d9132c7b..6d5c0a1599 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -26,6 +26,10 @@ Library run_forever() and run_until_complete() methods of asyncio.BaseEventLoop now raise an exception if the event loop was closed. +- Issue #21774: Fixed NameError for an incorrect variable reference in the + XML Minidom code for creating processing instructions. + (Found and fixed by Claudiu Popa.) + - Issue #21766: Prevent a security hole in CGIHTTPServer by URL unquoting paths before checking for a CGI script at that path.