Mantis Bugtracker 

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008551TestLinkAPI - XMLRPCpublic2019-01-29 16:592020-02-09 12:14
Assigned To 
PlatformVMOSCent OSOS Version
Product Version1.9.17 (2018 Q1) 
Fixed in Version 
Summary0008551: Can't upload an execution attachment bigger than 400Ko
DescriptionSimilar to bug id 0005055

When uploading a large file (>400Ko) with a test case result using XML-RPC, an exception occurs :

br.eti.kinoshita.testlinkjavaapi.util.TestLinkAPIException: Error uploading attachment for execution: parse error. not well formed
Steps To ReproduceUpload a 4Mo file via XML-RPC
Additional InformationI've patch it in class-IXR.php, same problem as report in bug id 0005055.
Not sure it's the best (not even a good) way to correct it.

function parse() {
        // Goal of this is to avoid too long lines for first line
        $this->message = str_replace("><",">\n<",$this->message);
        // first remove the XML declaration
        $this->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $this->message,1);

        if (trim($this->message) == '') {
            return false;
TagsNo tags attached.
Database (MySQL,Postgres,etc)mariaDB
PHP Version
QA Team - Task Workflow Status
Attached Files

- Relationships

-  Notes
Mat83 (reporter)
2019-01-29 17:01


was only for debug :)
fman (administrator)
2019-01-30 09:37

In addition to the code, some comment explaining how this has been fixed is a must.
Mat83 (reporter)
2019-01-30 13:55

searching on the net I found the bug id 0005055 with same error,
then I checked that the error occurs at same place, when trying to remove the XML declaration. So I dump the message with :
The message is only on 1 ligne, and seems to be well formed.
I conclude the preg_replace can't manage a so long line, even with the bug id 5055 correction.
So I try to change the xml message with some \n between xml tag,
and no more error occurs.

hoping this answers the request, first time I post a bug on mantis ...
fman (administrator)
2019-01-31 09:03

First or not first one reporting has no difference.
Please follow defacto standards for issue reporting
Mat83 (reporter)
2019-02-01 11:00

Some more information :
testlink installation is from bitnami docker 1.9.17 (PHP 7.1.23),
xml is generated from testlink-plugin (3.14) for jenkins (2.138.2)
jburgers (reporter)
2019-10-01 12:50

Changing this line

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

for these two ones

$header = preg_replace('/<\?xml(.*)?\?'.'>/', '', substr($this->message, 0, 100),1);
$this->message = substr_replace($this->message, $header, 0, 100);

worked for me. I have tested with a 5MB attachment.

I have never worked before with PHP, so don't know if it is ok doing that.

(I took these guys work as reference: [^])
heju (reporter)
2020-01-07 12:26
edited on: 2020-01-07 12:26

Hi @jburgers,

I noticed, that for slightly larger files than your test sample of 5MB, it fails again!

However in your linked file, there is already the fix:

Replace the whole function "function parse()", not only the first difference.

As this version has the additional improvement of parsing in chunks rather than the whole msg at once.

Tested with 109MB, upload works.

jburgers (reporter)
2020-02-09 12:14

Hi @heju,

I'll do that, thanks!

- Issue History
Date Modified Username Field Change
2019-01-29 16:59 Mat83 New Issue
2019-01-29 17:01 Mat83 Note Added: 0028476
2019-01-30 09:37 fman Note Added: 0028480
2019-01-30 13:55 Mat83 Note Added: 0028485
2019-01-31 09:03 fman Note Added: 0028487
2019-02-01 11:00 Mat83 Note Added: 0028491
2019-10-01 12:50 jburgers Note Added: 0029232
2020-01-07 12:26 heju Note Added: 0029395
2020-01-07 12:26 heju Note Edited: 0029395 View Revisions
2020-02-09 12:14 jburgers Note Added: 0029470

Copyright © 2000 - 2020 MantisBT Team
Powered by Mantis Bugtracker