[wp-trac] [WordPress Trac] #6701: XmlRpc responses truncated due to
UTF-8 BOM
WordPress Trac
wp-trac at lists.automattic.com
Sat Apr 12 20:46:54 GMT 2008
#6701: XmlRpc responses truncated due to UTF-8 BOM
-------------------------+--------------------------------------------------
Reporter: aaron.oneal | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone: 2.7
Component: XML-RPC | Version: 2.5
Severity: normal | Keywords: UTF-8 BOM Live Writer
-------------------------+--------------------------------------------------
Responses for XmlRpc are truncated due to the presence of the UTF-8 BOM.
The BOM adds an additional 3 bytes to the beginning of the response, but
the content length for the HTTP response is not updated to take that into
account. This results in the last 3 bytes of the response getting cut off
which results in malformed XML. This causes problems with Windows Live
Writer, for example.
This is easily witnessed using NetMon to capture traffic.
{{{
Frame:
+ Ethernet: Etype = Internet IP (IPv4)
+ Ipv4: Next Protocol = TCP, Packet ID = 18565, Total IP Length = 821
+ Tcp: Flags=...PA..., SrcPort=HTTP(80), DstPort=24091, Len=781,
Seq=370821372 - 370822153, Ack=995613184, Win=64808 (scale factor not
found)
- Http: Response, HTTP/1.1, Status Code = 200
- Response:
ProtocolVersion: HTTP/1.1
StatusCode: 200, Ok
Reason: OK
ContentLength: 551
ContentType: text/xml
Server: Microsoft-IIS/6.0
XPoweredBy: PHP/5.2.4
MicrosoftOfficeWebServer: 5.0_Pub
XPoweredBy: ASP.NET
Date: Sat, 12 Apr 2008 19:37:29 GMT
Connection: close
HeaderEnd: CRLF
- payload: HttpContentType = text/xml
- XmlPayload:

<?xml version="1.0"?>
- <methodResponse>
- <params>
- <param>
- <value>
- <array>
- <data>
- <value>
- <struct>
- <member>
- <name>
isAdmin
</name>
- <value>
- <boolean>
1
</boolean>
</value>
</member>
+ <member>
- <member>
- <name>
blogid
</name>
+ <value>
</member>
+ <member>
</struct>
</value>
</data>
</array>
</value>
</param>
</params>
</methodRespons
}}}
The closing tag is truncated.
I fixed this in my local copy by updating class-IXR.php to add 3 bytes to
the string length used to populate the Content-Length.
{{{
function output($xml) {
$xml = '<?xml version="1.0"?>'."\n".$xml;
$length = strlen($xml)+3;
header('Connection: close');
header('Content-Length: '.$length);
header('Content-Type: text/xml');
header('Date: '.date('r'));
echo $xml;
exit;
}
}}}
--
Ticket URL: <http://trac.wordpress.org/ticket/6701>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list