Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backports.xmlrpc.server's SimpleXMLRPCServer causes a bad xml string #585

Open
Amir-Hadadi opened this issue Feb 11, 2021 · 0 comments
Open

Comments

@Amir-Hadadi
Copy link

Amir-Hadadi commented Feb 11, 2021

Hi all,
After seeing the absence of SimpleXMLRPCServer from xmlrpc.server, I decided to use the given future.backports.xmlrpc.server.

One big change from the 2.x version is encoding the xml response, creating a newbytes (from SimpleXMLRPCDispatcher's _marshaled_dispatch):
return response.encode(self.encoding)
This encoding - creation of a newbytes object, wasn't there in 2.7, making me believe the new version wants to send encoded bytes instead of strings over the network, but later, when the data is written using SimpleXMLRPCRequestHandler's do_POST:
self.wfile.write(response)
What actually happens there is socket.py doing str() on the newbytes object, creating a string containing the b prefix: "b\'<xml...>'"
(note, it's not b"<xml...>", the b is actually in the string)

This string isn't read well later by xmlrpc.client.ProxyServer, which uses a parser that says this is an invalid xml string.

Here's a super simple project I made that showcases the problem, with a 2.x vs futurized code
https://github.com/Amir-Hadadi/xmlrpc-future-test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant