Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.1.5

Bug #13145 Server sends the wrong content-length header if mbstring is used
Submitted: 2008-02-19 00:02 UTC
From: gauthierm Assigned: sergiosgc
Status: Closed Package: XML_RPC2
PHP Version: 5.2.5 OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2008-02-19 00:02 UTC] gauthierm (Michael Gauthier)
Description: ------------ XML_RPC2_Server specifies a HTTP Content-length header. The length is calculated using strlen(). It mbstring.func_overload is used to overload the strlen() function, strlen() will return the number of characters in a string rather than the number of bytes. Since HTTP expects the number of bytes, multibyte characters inside an XML-RPC response will cause an incorrect Content-length header to be sent. This breaks various HTTP clients in weird and not-so-wonderful ways. When PHP supports unicode, strlen() will also report the number of characters rather than bytes unless a binary cast is used. The patch at: http://labs.silverorange.com/files/pear-patches/XML_RPC2-strlen-utf8-20080218.diff fixes the problem for both mbstring users and future versions of PHP. Test script: --------------- http://labs.silverorange.com/files/tests/XML_RPC2-utf8-strlen-test.phps Expected result: ---------------- Content-length header is: 19 (bytes) Actual result: -------------- Result with (mb_string.func_overload & 2) == 2 Content-length header is 15 (bytes)

Comments

 [2008-05-06 18:59 UTC] gauthierm (Michael Gauthier)
Any update on this bug? There is a working patch attached to this report.
 [2008-09-10 19:09 UTC] sergiosgc (Sérgio Carvalho)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/XML_RPC2