MantisBT - TestLink
View Issue Details
0005055TestLinkAPI - XMLRPCpublic2012-06-08 23:262014-04-25 17:38
X64Mac OS X10.7.4
1.9.3 (2011 Q3 - bug fixing) 
1.9.10 (2014 Q1 - bug fixing) 
Frefox 13
0005055: Error attaching file via XMLRPC API
When I try to send a file higher than 60kb I received the following message: "parse error. not well formed"
I'm trying to send this attachment with a Java code. I know that Java is not the problem, but it always happens for a file higher tha 60kb.

With this error it's not usefull use this functionality (I'm using this to upload an image in every failed test case in test execution) because any screenshot that I capture have more than 60kb.

There's a issue on apache XMLRCP project explain that [^]
Probably it will not solved... =/

The full exception:
Caused by: org.apache.xmlrpc.XmlRpcException: parse error. not well formed
    at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(
    at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(
    at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(
    at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(
    at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(
    at org.apache.xmlrpc.client.XmlRpcClient.execute(
    at org.apache.xmlrpc.client.XmlRpcClient.execute(
    at org.apache.xmlrpc.client.XmlRpcClient.execute(

No tags attached.
child of 0006048closed fman Availables hot-fixes for 1.9.9 & How To get full fixed package from gitorious 
Issue History
2012-06-08 23:26eliasnNew Issue
2012-06-09 16:04fmanNote Added: 0016849
2012-06-09 16:05fmanNote Added: 0016850
2012-06-11 03:23kinowNote Added: 0016852
2012-07-02 16:39kinowAssigned To => kinow
2012-07-02 16:39kinowStatusnew => assigned
2013-04-25 17:30fmanCategoryTL API => XMLRPC API
2013-04-25 17:30fmanCategoryXMLRPC API => API - XMLRPC
2013-12-18 18:08moormanmNote Added: 0020223
2013-12-18 18:16moormanmNote Edited: 0020223bug_revision_view_page.php?bugnote_id=20223#r3264
2013-12-18 18:18fmanNote Added: 0020224
2013-12-18 18:18fmanQA Team - Task Workflow Status => TBD
2013-12-18 18:18fmanSummaryError in attachment => Error attaching file via XMLRPC API
2013-12-18 18:34kinowNote Added: 0020225
2013-12-20 23:17moormanmNote Added: 0020234
2013-12-25 12:19fmanNote Added: 0020240
2013-12-25 12:20fmanQA Team - Task Workflow StatusTBD => READY FOR TESTING
2013-12-25 12:20fmanFixed in Version => 1.9.10 (2014 Q1 - bug fixing)
2013-12-25 12:20fmanRelationship addedchild of 0006048
2014-04-25 14:49fmanStatusassigned => resolved
2014-04-25 14:49fmanResolutionopen => fixed
2014-04-25 17:38fmanNote Added: 0020802
2014-04-25 17:38fmanStatusresolved => closed

2012-06-09 16:04   
Can you test with our php client ?
2012-06-09 16:05   
Reminder sent to: kinow

can you give a look, first with our PHP example, then with a java client ? ( please add java client to stable code both on 1.9.4 and 2.0)
2012-06-11 03:23   
Sure thing Francisco. I've worked on a very similar issue in the java-api, so hopefully it won't be hard to reproduce this issue.

I will use our PHP example, and then the Java client. I will add the Java client to both versions as you suggested too :-) I'm just finishing the code for the CSRF issue, and then will resync my local repositories.

2013-12-18 18:08   
(edited on: 2013-12-18 18:16)
I too ran into this issue with large files.

I did some debugging on the testlink API side and pinned the problem down to the xmlrpc library in third_party/xml-rpc/class-IXR.php.

In the parse() function of the IXR_Message class, there is a block of code:

$this->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $this->message);
if (trim($this->message) == '') {
  return false;

For large attachments, preg_replace is hitting the php backtrack limit setting, which is 100k by default. When the backtrack limit is exceeded, preg_replace returns an empty string.

You can set the backtrack limit in php.ini with:

You might also want/need to up the recursion limit, max post size, and max file upload limits:


In the /class-IXR.php, it would be nice if it checked for the backtrack limit error and then bubble up a better error message to the user:

if (trim($this->message) == '') {
   if (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR) {
      //Backtrack limit was hit, bubble up error
   return false;


I think you can avoid the memory issue all together by using the optional "limit" parameter in the preg_replace function.

$this->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $this->message, 1); [^]

2013-12-18 18:18   
OK, thanks
we are going to understand if we can add this as a permanet fix
2013-12-18 18:34   
@moormanm, would you like to submit a patch for this? :)
2013-12-20 23:17   
I made a merge request: [^]

I'm new at this, hopefully the request is targeted properly :-)
2013-12-25 12:19   
applied change on branch 1.9 [^]
2014-04-25 17:38   
1.9.10 released