Skip to content

Commit

Permalink
Fix #2974 - Invalid Chars in JUnit XML
Browse files Browse the repository at this point in the history
JUnit XML (produced with --log-junit) is invalid (and won't be opened by
some programs) if it contains invalid XML characters in the <system-out>
node. Fix this by sanitizing text before adding it to the XML.
  • Loading branch information
mkasberg authored and sebastianbergmann committed Feb 16, 2018
1 parent 3330ef2 commit ff187f9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Util/Log/JUnit.php
Expand Up @@ -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);
Expand Down

0 comments on commit ff187f9

Please sign in to comment.