summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-05-04 08:27:17 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-05-04 08:27:17 (GMT)
commit45cdcd93c9e4b16437610cfb69205d3379bee61a (patch)
tree5851075175387ac16712ba583a0dca39ca56041b
parentc2f7d878972db908f5a1bad7af94c692b6d8c564 (diff)
parent290fed43d9cdcd3d738dda319e63e26d7972d734 (diff)
downloadcpython-45cdcd93c9e4b16437610cfb69205d3379bee61a.zip
cpython-45cdcd93c9e4b16437610cfb69205d3379bee61a.tar.gz
cpython-45cdcd93c9e4b16437610cfb69205d3379bee61a.tar.bz2
Issue #26873: xmlrpc now raises ResponseError on unsupported type tags
instead of silently return incorrect result.
-rw-r--r--Lib/test/test_xmlrpc.py14
-rw-r--r--Lib/xmlrpc/client.py3
-rw-r--r--Misc/NEWS3
3 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index 59f9c32..0773a86 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -223,6 +223,20 @@ class XMLRPCTestCase(unittest.TestCase):
self.assertIs(type(newvalue), xmlrpclib.Binary)
self.assertIsNone(m)
+ def test_loads_unsupported(self):
+ ResponseError = xmlrpclib.ResponseError
+ data = '<params><param><value><spam/></value></param></params>'
+ self.assertRaises(ResponseError, xmlrpclib.loads, data)
+ data = ('<params><param><value><array>'
+ '<value><spam/></value>'
+ '</array></value></param></params>')
+ self.assertRaises(ResponseError, xmlrpclib.loads, data)
+ data = ('<params><param><value><struct>'
+ '<member><name>a</name><value><spam/></value></member>'
+ '<member><name>b</name><value><spam/></value></member>'
+ '</struct></value></param></params>')
+ self.assertRaises(ResponseError, xmlrpclib.loads, data)
+
def test_get_host_info(self):
# see bug #3613, this raised a TypeError
transp = xmlrpc.client.Transport()
diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py
index 77e20ec..581a3b9 100644
--- a/Lib/xmlrpc/client.py
+++ b/Lib/xmlrpc/client.py
@@ -640,6 +640,7 @@ class Unmarshaller:
self._stack = []
self._marks = []
self._data = []
+ self._value = False
self._methodname = None
self._encoding = "utf-8"
self.append = self._stack.append
@@ -669,6 +670,8 @@ class Unmarshaller:
if tag == "array" or tag == "struct":
self._marks.append(len(self._stack))
self._data = []
+ if self._value and tag not in self.dispatch:
+ raise ResponseError("unknown tag %r" % tag)
self._value = (tag == "value")
def data(self, text):
diff --git a/Misc/NEWS b/Misc/NEWS
index bae8c7b..db22c2b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -256,6 +256,9 @@ Core and Builtins
Library
-------
+- Issue #26873: xmlrpc now raises ResponseError on unsupported type tags
+ instead of silently return incorrect result.
+
- Issue #26711: Fixed the comparison of plistlib.Data with other types.
- Issue #24114: Fix an uninitialized variable in `ctypes.util`.