xml-rpc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dustin Sallings <dustin+xml...@spy.net>
Subject base64 interop problems
Date Thu, 27 Jun 2002 17:27:36 GMT

	Hi, I'm using the Apache XML-RPC code in a project and I had some
bad interoperability problems when using a non-Apache client.

	Specifically, when I used the python client to send a binary of
about 700k, it gained about 10k in the decoding.  This seems to be because
the decoder does not do anything to skip input characters that are not
valid input characters.  In particular, section 6.8 of RFC 2045 states the
following:

	The encoded output stream must be represented in lines of no more
   than 76 characters each.  All line breaks or other characters not
   found in Table 1 must be ignored by decoding software.  In base64
   data, characters other than those in Table 1, line breaks, and other
   white space probably indicate a transmission error, about which a
   warning message or even a message rejection might be appropriate
   under some circumstances.

	The python encoder was indeed sending 76 character lines, which
seemed to be the problem.

	Not wanting to spend a lot of time getting this thing going, I
replaced the base64 decoder with one that I had written and have done
interop testing with.  The patch is included, and you guys are free to do
what you want with it.

	Like the original decoder, it does not throw an exception on
invalid input, it instead tried to decode as best as it can.  It may be
more appropriate here to throw an exception if the invalid character is
not a whitespace, i.e. change this:

            // Skip over invalid characters.
            if(x<0) {
                invalid++;
                continue;
            }

	to

        // Skip over invalid characters.
        if(x<0) {
	    if(!Character.isWhitespace(input.charAt(i))) {
                throw new IOException("Invalid Base64 character found");
            }
            // Otherwise, mark it and continue
            invalid++;
            continue;
        }

	Anyway, you guys are free to do with this code as you please, but
I'm using it in the meantime to make my app work.

--
SPY                      My girlfriend asked me which one I like better.
pub  1024/3CAE01D5 1994/11/03 Dustin Sallings <dustin@spy.net>
|    Key fingerprint =  87 02 57 08 02 D0 DA D6  C8 0F 3E 65 51 98 D8 BE
L_______________________ I hope the answer won't upset her. ____________

Mime
View raw message