Mantis Bugtracker          
testlink.org

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008551TestLinkAPI - XMLRPCpublic2019-01-29 16:592020-01-07 12:26
ReporterMat83 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusnewResolutionopen 
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
        file_put_contents("/tmp/res.txt",$this->message);
        $this->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $this->message,1);

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

- Relationships

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

file_put_contents("/tmp/res.txt",$this->message);

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

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

Hello,
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 :
file_put_contents("/tmp/res.txt",$this->message);
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 ...
(0028487)
fman (administrator)
2019-01-31 09:03

First or not first one reporting has no difference.
Please follow defacto standards for issue reporting
(0028491)
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)
(0029232)
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: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-IXR.php?rev=25001&order=name [^])
(0029395)
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.


- 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



Copyright © 2000 - 2020 MantisBT Team
Powered by Mantis Bugtracker