[s-xml-rpc-devel] bug: S-XML-RPC sends unencoded strings with invalid characters

Taylor R Campbell campbell at mumble.net
Fri Jul 28 16:10:17 UTC 2006


   Date: Fri, 28 Jul 2006 15:18:16 +0200
   From: Sven Van Caekenberghe <scaekenberghe at common-lisp.net>

   Could you please be a bit more specific ? It has been a while since I  
   have been reading these specs ;-)

   The function s-xml:print-string-xml does a bit of escaping and is  
   used from s-xml-rpc::encode-xml-rpc-value, what exactly are they  
   doing wrong ?

S-XML:PRINT-STRING-XML does do certain escaping, but some code points
are invalid even if escaped as entity references.  The particular
problem I had was that lisppaste was sending me the contents of a
paste with an ASCII form feed character, i.e. U+0C, which is not
allowed in well-formed XML, even as an entity reference -- that is,
the XML specification forbids &#xC;.  To get around this, any XML-RPC
message containing such a character (or any character below U+0C that
is not U+09, U+0A, or U+0D) must be base64-encoded first.

   Could you give some concrete example, a CL listener session maybe ?
   I know that s-xml-rpc is used by a couple of other projects/people,  
   so changing the string encoding must be done carefully.

CL-USER> (s-xml:print-xml-string (string (code-char #x0C)))
"&#xC;"
CL-USER> (s-xml-rpc::encode-xml-rpc-value (string (code-char #x0C)) t)
<value><string>&#xC;</string></value>
"</value>"
CL-USER> 

S-XML:PRINT-XML-STRING should signal an error if any such characters
are encountered, and S-XML-RPC::ENCODE-XML-RPC-VALUE should instead
base64-encode the string and generate this output:

<value><base64>DA==</base64></value>



More information about the S-xml-rpc-devel mailing list