xmlrpc server returning not well formed xml in some cases

Bug #143133 reported by Maciej Pietrzak
2
Affects Status Importance Assigned to Milestone
Zope 2
Invalid
Low
Unassigned

Bug Description

xmlrpc response contains exception information, which is included as is.

if exception has "strange" characters (not utf-8 characters) resulting xml is not well formed xml.

xmlrpc server implementation should always return valid xml. if there's an error on server side, an Fault object should be returned. suppose there is an error (offending exception), there's an another error - bad encoding in exceptions's description (this one is light), response should be a valid xml anyway.

proposed solution: test strings against .decode('utf-8') and include repr() it this throws exception unicode exception. this (i guess) should be faster than trying to parse xml after is is constructed.

thanks.

Tags: bug zope
Revision history for this message
Maciej Pietrzak (godefroy) wrote :

Uploaded: xmlrpc-fault.patch

Example patch.

In case that fault description is not valid utf-8 string it replaces all chars that are > 127 to question marks.

This can be done with re or doing "value = repr(value)" - I don't know which is faster. Patched code just iterates over the string chars.

Patch against current svn revision: 27314.

HTH.

Revision history for this message
Florent Guillaume (efge) wrote :

Please give an example of code that provokes such an exception otherwise we can't write a unit test.

Tres Seaver (tseaver)
Changed in zope2:
status: New → Incomplete
Revision history for this message
Colin Watson (cjwatson) wrote :

The zope2 project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/zope2.

Changed in zope2:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.