python / cpython

The Python programming language
https://www.python.org
Other
62.47k stars 29.99k forks source link

xmlrpclib.Binary doesn't say which base64 spec it implements #45195

Closed 5d5674c0-b2f5-475c-90db-243ac14d9ece closed 16 years ago

5d5674c0-b2f5-475c-90db-243ac14d9ece commented 17 years ago
BPO 1753732
Nosy @loewis, @smontanaro
Files
  • libxmlrpclib.patch: Patch against Doc/lib/libxmlrpclib.tex from trunk
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields: ```python assignee = 'https://github.com/smontanaro' closed_at = created_at = labels = ['easy', 'docs'] title = "xmlrpclib.Binary doesn't say which base64 spec it implements" updated_at = user = 'https://bugs.python.org/slinkp' ``` bugs.python.org fields: ```python activity = actor = 'benjamin.peterson' assignee = 'skip.montanaro' closed = True closed_date = closer = 'benjamin.peterson' components = ['Documentation'] creation = creator = 'slinkp' dependencies = [] files = ['2420'] hgrepos = [] issue_num = 1753732 keywords = ['patch', 'easy'] message_count = 7.0 messages = ['32500', '32501', '32502', '32503', '32504', '65693', '65699'] nosy_count = 3.0 nosy_names = ['loewis', 'skip.montanaro', 'slinkp'] pr_nums = [] priority = 'normal' resolution = 'fixed' stage = None status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue1753732' versions = [] ```

    5d5674c0-b2f5-475c-90db-243ac14d9ece commented 17 years ago

    xmlrpclib.Binary.encode() does base64 encoding. But there are actually two conflicting specs: RFC 2045 says add newlines every 76 characters, RFC 3548 says do NOT add newlines.

    The xmlrpc spec characteristically doesn't mention an RFC, so it's not clear which spec they mean by "base64". By looking at the dates on the various specs, it can be inferred that they must mean MIME-style with newlines, as per RFC 2045. That's xmlrpclib does.

    But for those of us implementing stuff in the trenches and struggling with interoperability issues, it would be nice if the python docs were more informative so we don't have to go spiraling off into reading multiple specs and figuring out which came first :)

    So I'd suggest changing the Binary.encode docstring to something like:

    """Write the XML-RPC base 64 encoding of this binary item to the out stream object.

    Note that the encoded data will have newlines every 76 characters as per RFC 2045, which was the de facto standard base64 specification when the xmlrpc spec was written."""

    Arguably, the behavior could be changed instead - due to the xmlrpc spec's silence on the subject, not all clients may tolerate newlines (Redstone doesn't)... but that's a separate argument :)

    61337411-43fc-4a9c-b8d5-4060aede66d0 commented 17 years ago

    Note that RFC 3548 is informational, so it is not a specification (at least not of an internet protocol).

    Also notice that Python's xmlrpclib library is not the specification or de-facto implementation of XML-RPC, either. The official XML-RPC specification is at

    http://www.xmlrpc.com/spec

    According to that specification, the only possibilities are that Python's implementation is either conforming or not conforming. If it is not conforming, it should be changed; if it is conforming, it should stay, and Redstone should be changed.

    5d5674c0-b2f5-475c-90db-243ac14d9ece commented 17 years ago

    Thanks Loewis, but I am well aware of the xmlrpc spec. As I said in my original bug report: The spec alone is too vague to tell us which base64 specification xmlrpclib should conform *to*, and thus we can't say whether xmlrpclib does or does not conform. Your yes/no question is thus unanswerable. In my opinion this means the spec is broken, but there's apparently no chance of an official update.

    I brought this up on the xmlrpc yahoo list. http://tech.groups.yahoo.com/group/xml-rpc/message/6650

    Some excerpts from relevant responses: "The fact is, the spec has been frozen - "cast in stone" in the words of the author - since 1999, and there is absolutely 0% chance of an official update." - http://tech.groups.yahoo.com/group/xml-rpc/message/6651

    "It would be nice to have a document that describes what "everyone does," but ... http://effbot.org/zone/xmlrpc-errata.htm does a good job too. Note that the latter clearly says you can split base64 lines if you want. ... I believe that essentially all XML-RPC implementations use MIME-style (RFC 2045) base64 encoding -- i.e. with line breaks." - http://tech.groups.yahoo.com/group/xml-rpc/message/6653

    Finally, about the Redstone problem that led me to post this report: "I have just looked at the Redstone Bas64 decoder and it's obviously broken. The code correctly ignores whitespace characters but then complains that the data is too short."

    I have filed a bug report against Redstone: http://sourceforge.net/tracker/index.php?func=detail&aid=1753822&group_id=25164&atid=383547

    From the responses so far, I don't think a change to Python's behavior is warranted. I *do* still think it would be useful to clarify the xmlrpclib documentation as I've suggested in this bug report, so users know what to expect. Is there any good reason NOT to do this?

    A link to the official spec at http://www.xmlrpc.com/spec should also be added to the "See also" links, possibly along with a link to Fred's unofficial errata at http://effbot.org/zone/xmlrpc-errata.htm

    61337411-43fc-4a9c-b8d5-4060aede66d0 commented 17 years ago

    More documentation is always a good idea. Can you provide a patch (as a context or unified patch) against the sources of the documentation?

    5d5674c0-b2f5-475c-90db-243ac14d9ece commented 17 years ago

    Sure. Patch against Doc/lib trunk attached. File Added: libxmlrpclib.patch

    smontanaro commented 16 years ago

    I updated xmlrpclib.rst with your documentation changes (r62465). Is it okay to close this ticket?

    Skip

    5d5674c0-b2f5-475c-90db-243ac14d9ece commented 16 years ago

    looks good to me, thanks!