Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2)

Unified Diff: Lib/xmlrpclib.py

Issue 26147: Encoding errors in xmlrpc
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_xmlrpc.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/xmlrpclib.py Mon Jan 18 19:38:53 2016 +0200
+++ b/Lib/xmlrpclib.py Mon Jan 18 20:21:19 2016 +0200
@@ -703,9 +703,8 @@ class Marshaller:
if unicode:
def dump_unicode(self, value, write, escape=escape):
- value = value.encode(self.encoding)
write("<value><string>")
- write(escape(value))
+ write(escape(value).encode(self.encoding, 'xmlcharrefreplace'))
write("</string></value>\n")
dispatch[UnicodeType] = dump_unicode
@@ -732,12 +731,13 @@ class Marshaller:
write("<value><struct>\n")
for k, v in value.items():
write("<member>\n")
- if type(k) is not StringType:
- if unicode and type(k) is UnicodeType:
- k = k.encode(self.encoding)
- else:
- raise TypeError, "dictionary key must be string"
- write("<name>%s</name>\n" % escape(k))
+ if type(k) is StringType:
+ k = escape(k)
+ elif unicode and type(k) is UnicodeType:
+ k = escape(k).encode(self.encoding, 'xmlcharrefreplace')
+ else:
+ raise TypeError, "dictionary key must be string"
+ write("<name>%s</name>\n" % k)
dump(v, write)
write("</member>\n")
write("</struct></value>\n")
@@ -1099,7 +1099,7 @@ def dumps(params, methodname=None, metho
if methodname:
# a method call
if not isinstance(methodname, StringType):
- methodname = methodname.encode(encoding)
+ methodname = methodname.encode(encoding, 'xmlcharrefreplace')
data = (
xmlheader,
"<methodCall>\n"
« no previous file with comments | « Lib/test/test_xmlrpc.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+