Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Lib/test/test_xmlrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,18 @@ def test_loads_unsupported(self):
'</struct></value></param></params>')
self.assertRaises(ResponseError, xmlrpclib.loads, data)

def test_loads_nested_scalars(self):
template = '<params><param><value>%s</value></param></params>'
# CDATA splits 'ab' into two fragments so that joining them again
# would allocate another string. str.join() can reuse a single fragment.
data = template % '<string><string>a<![CDATA[b]]></string></string>'
Comment thread
woodruffw marked this conversation as resolved.
Resolved
values, _ = xmlrpclib.loads(data)
self.assertEqual(values, ('ab', ''))

data = template % '<int><int>1</int>2</int>'
values, _ = xmlrpclib.loads(data)
self.assertEqual(values, (1, 2))

def check_loads(self, s, value, **kwargs):
dump = '<params><param><value>%s</value></param></params>' % s
result, m = xmlrpclib.loads(dump, **kwargs)
Expand Down
4 changes: 3 additions & 1 deletion Lib/xmlrpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,9 @@ def end(self, tag):
f = self.dispatch[tag.split(':')[-1]]
except KeyError:
return # unknown tag ?
return f(self, "".join(self._data))
data = "".join(self._data)
self._data.clear()
return f(self, data)

#
# accelerator support
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix quadratic memory use in :mod:`xmlrpc.client` when decoding malformed
Comment thread
woodruffw marked this conversation as resolved.
Resolved
XML-RPC packets containing nested string elements. This can cause ``loads()``
to raise on malformed packets that were previously silently accepted.
Loading