[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs-25 b6b47AF: Properly encode/decode base64Binary data in SOAP

From: Thomas Fitzsimmons
Subject: Re: emacs-25 b6b47AF: Properly encode/decode base64Binary data in SOAP
Date: Thu, 10 Mar 2016 22:29:16 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

Andreas Schwab <address@hidden> writes:

> Thomas Fitzsimmons <address@hidden> writes:
>> <originator 
>> xsi:type="xsd:base64Binary">Wm9sdMOhbiBLcmFqY3NvdmljcyA8enVsdGhhbmtAZ21haWwuY29tPg==</originator>
>> The test suite expects this to decode as:
>> Zolt\303\241n Krajcsovics [...]
> Leaving it undecoded is definitely wrong.  Undecoded strings should
> never be used inside Emacs, except for interaction with external
> sources.

Agreed, but I disagree that soap-client itself should be doing the
decoding.  SOAP messages are sent to and received from external sources.
In general, an elisp function receiving base64-encoded data from an
external source, via a soap-client call, will want to see it first as a
unibyte string of bytes, in case it's image data or some other
non-string data.  If the soap-client caller expects it to be a UTF-8
encoded string, the caller can attempt the string decoding.

>> Do you have an example SOAP message that your patch fixes, and can the
>> surrounding code do the UTF-8 encoding/decoding instead of soap-client
>> itself?
> (debbugs-get-status 22285)

OK, thanks.  The originator field there is base64 binary.  Without your

(multibyte-string-p (cdr (assoc 'originator (car (debbugs-get-status 22285)))))
=> nil
(length (cdr (assq 'originator (car (debbugs-get-status 22285)))))
=> 51

With your patch:

(multibyte-string-p (cdr (assoc 'originator (car (debbugs-get-status 22285)))))
=> t
(length (cdr (assq 'originator (car (debbugs-get-status 22285)))))
=> 50

Before your patch, what problem did you see?  Did some caller of
debbugs-get-status show raw characters somewhere, i.e., did it assume
originator was an already-decoded UTF-8 string?  If so, I think that
caller should be fixed (and soap-client should go back to its old
behavior of leaving the string undecoded).

To see what other callers do, I tried (debbugs-org-bugs 22285); it
decodes the originator field itself:

  (originator (when (cdr (assq 'originator status))
                 (cdr (assq 'originator status)) 'utf-8)))

which correctly shows the "LATIN SMALL LETTER E WITH ACUTE" in the
*Org Bugs* buffer with the old soap-client behavior.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]