Re: CRLF in <string> -- XML vs XML-RPC

"Gaetano Giunta" <[email protected]> Wed, 9 May 2007 10:10:12 +0200
Newsgroups gmane.text.xml.rpc.specification
Message-ID <[email protected]>
>> by default I encode using &#xxxx; notation EVERY char outside ASCII
>> range when sending. That means, for 8 bit charset (php defaults to
>> iso-8859-1 basically), chars <= 32 and >= 160. It is the best solution
>> I could come up to make sure the charset transcoding errors are kept
>> to a minimum. Plus CR LF are always sent and received as-is.

>> Note: the php application can, when using the lib, specify it desires
>> to encode sent data as iso-8859-1 or UTF-8, in which case I do not
>> convert \r or \n chars to their code point representation - and I do
>> not normalize upon sending, either.

> I can't see a difference between the default and the option. When do
> you send \r \n as the raw characters and when don't you? When you say
> "code point representation," which representation is that? &#xxxx; ?

Sorry for my poor wording. I am always very bad at using the correct terms.
By "code point representation" I did mean "&#xxxx;" representation, or, as it is named in the spec, "character reference"

I do send \r \n as "raw" characters when the user of the library specifies via a specific call that he wants to use a particular character set for the outgoing payload.
Since the supported charsets (by the lib) are ISO-8859-1 and UTF8 only, raw CR and LF chars are deemed to be valid.
If the user of the lib does not specify anything, I do the "always encode using character represenation trick", and send character representation for \r and \n.

One other thing I do, which I did not mention is that by default I do not send any charset header in neither the xml prologue nor the http headers, but when the lib user specifies the charset he wants to use I do set it in both places. 

Oh, and I also send '&amp;', '&quot;', '&apos;', '&lt;', '&gt;' as entity references instead of cahrcter references. This is done basically to satisfy 'to the letter' the xmlrpc spec, which says "... except < and &, which are encoded as &lt; and &amp;"

>> when receiving, the php xml parser is used. It is expat-based. As
>> far as I can tell, i does not normalize CR\LF while decoding

> That's hard to believe. You mean the conventional PHP XML parser
> doesn't normalize CR/LF ever? Considering 1) that the XML spec makes
> it pretty clear that it's required; and 2) it's generally very useful,
> I don't think it could get away with that. Plus, I have an Expat
> parser from 2001 that has the normalization integrated pretty tightly
> into it.

Well, I quoted from memory, and I am most likely wrong.
I just re-read the spec, and as you correctly pointed out in chapter 2.11 the normalization is in fact required upon parsing.

Bye
Gaetano


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/xml-rpc/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/xml-rpc/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/