From ff187f905c6ccf7ec615c814bdfbba82a6abf693 Mon Sep 17 00:00:00 2001 From: Mike Kasberg Date: Thu, 15 Feb 2018 22:30:13 -0700 Subject: [PATCH] Fix #2974 - Invalid Chars in JUnit XML JUnit XML (produced with --log-junit) is invalid (and won't be opened by some programs) if it contains invalid XML characters in the node. Fix this by sanitizing text before adding it to the XML. --- src/Util/Log/JUnit.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Util/Log/JUnit.php b/src/Util/Log/JUnit.php index 6d46b4d1002..15101878e3e 100644 --- a/src/Util/Log/JUnit.php +++ b/src/Util/Log/JUnit.php @@ -362,10 +362,9 @@ public function endTest(Test $test, $time) $this->testSuiteTimes[$this->testSuiteLevel] += $time; if (\method_exists($test, 'hasOutput') && $test->hasOutput()) { - $systemOut = $this->document->createElement('system-out'); - - $systemOut->appendChild( - $this->document->createTextNode($test->getActualOutput()) + $systemOut = $this->document->createElement( + 'system-out', + Xml::prepareString($test->getActualOutput()) ); $this->currentTestCase->appendChild($systemOut);