MantisBT - TestLink
View Issue Details
0005055TestLinkAPI - XMLRPCpublic2012-06-08 23:262014-04-25 17:38
eliasn 
kinow 
highmajoralways
closedfixed 
X64Mac OS X10.7.4
1.9.3 (2011 Q3 - bug fixing) 
1.9.10 (2014 Q1 - bug fixing) 
MySQL
Frefox 13
READY FOR TESTING
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 https://issues.apache.org/jira/browse/XMLRPC-171 [^]
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(XmlRpcStreamTransport.java:197)
    at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:156)
    at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
    at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
    at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
    at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
    at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:158)
    at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:147)

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

Notes
(0016849)
fman   
2012-06-09 16:04   
Can you test with our php client ?
(0016850)
fman   
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)
(0016852)
kinow   
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.

Thanks
(0020223)
moormanm   
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:
pcre.backtrack_limit


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

pcre.recursion_limit
post_max_size
upload_max_filesize

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;
}


EDIT:

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);

http://www.php.net/preg_replace [^]

(0020224)
fman   
2013-12-18 18:18   
OK, thanks
we are going to understand if we can add this as a permanet fix
(0020225)
kinow   
2013-12-18 18:34   
@moormanm, would you like to submit a patch for this? :)
(0020234)
moormanm   
2013-12-20 23:17   
I made a merge request: https://gitorious.org/testlink-ga/testlink-code/merge_requests/9 [^]

I'm new at this, hopefully the request is targeted properly :-)
(0020240)
fman   
2013-12-25 12:19   
applied change on branch 1.9

https://gitorious.org/testlink-ga/testlink-code/commit/0c264bf2f3357cce3ffc6cecbd720ad4c287bec6 [^]
(0020802)
fman   
2014-04-25 17:38   
1.9.10 released