changeset: 101223:7050c9fc1f72 branch: 2.7 parent: 101219:e07e2b8c9429 user: Serhiy Storchaka date: Wed May 04 11:28:09 2016 +0300 files: Lib/test/test_xmlrpc.py Lib/xmlrpclib.py Misc/NEWS description: Issue #26873: xmlrpclib now raises ResponseError on unsupported type tags instead of silently return incorrect result. diff -r e07e2b8c9429 -r 7050c9fc1f72 Lib/test/test_xmlrpc.py --- a/Lib/test/test_xmlrpc.py Tue May 03 22:15:29 2016 +0300 +++ b/Lib/test/test_xmlrpc.py Wed May 04 11:28:09 2016 +0300 @@ -208,6 +208,20 @@ self.assertEqual(s, "abc \xc2\x95") self.assertEqual(items, [("def \xc2\x96", "ghi \xc2\x97")]) + def test_loads_unsupported(self): + ResponseError = xmlrpclib.ResponseError + data = '' + self.assertRaises(ResponseError, xmlrpclib.loads, data) + data = ('' + '' + '') + self.assertRaises(ResponseError, xmlrpclib.loads, data) + data = ('' + 'a' + 'b' + '') + self.assertRaises(ResponseError, xmlrpclib.loads, data) + class HelperTestCase(unittest.TestCase): def test_escape(self): diff -r e07e2b8c9429 -r 7050c9fc1f72 Lib/xmlrpclib.py --- a/Lib/xmlrpclib.py Tue May 03 22:15:29 2016 +0300 +++ b/Lib/xmlrpclib.py Wed May 04 11:28:09 2016 +0300 @@ -784,6 +784,7 @@ self._stack = [] self._marks = [] self._data = [] + self._value = False self._methodname = None self._encoding = "utf-8" self.append = self._stack.append @@ -814,6 +815,8 @@ 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 -r e07e2b8c9429 -r 7050c9fc1f72 Misc/NEWS --- a/Misc/NEWS Tue May 03 22:15:29 2016 +0300 +++ b/Misc/NEWS Wed May 04 11:28:09 2016 +0300 @@ -77,6 +77,9 @@ Library ------- +- Issue #26873: xmlrpclib now raises ResponseError on unsupported type tags + instead of silently return incorrect result. + - Issue #24114: Fix an uninitialized variable in `ctypes.util`. The bug only occurs on SunOS when the ctypes implementation searches