From: Matteo Beccati Date: Tue, 27 May 2014 09:04:48 +0000 (+0200) Subject: Fixed broken XML junit output due to escaping of CDATA sections X-Git-Tag: POST_PHPNG_MERGE~272^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b08c885ba5a53264c1b1be3c5a46a1e222b6008;p=php Fixed broken XML junit output due to escaping of CDATA sections I've removed CDATA and used htmlspecialchars as the output might not be UTF-8 safe, as pointed out by ircmaxell in 26b37f1792dfaf9b0b30f81e492c8f68b9ece571 --- diff --git a/run-tests.php b/run-tests.php index 030e95a684..cd57747b2f 100755 --- a/run-tests.php +++ b/run-tests.php @@ -1536,7 +1536,7 @@ TEST $file } $message = !empty($m[1]) ? $m[1] : ''; - junit_mark_test_as('SKIP', $shortname, $tested, null, ""); + junit_mark_test_as('SKIP', $shortname, $tested, null, $message); return 'SKIPPED'; } @@ -1561,7 +1561,7 @@ TEST $file ) { $message = "ext/zlib required"; show_result('SKIP', $tested, $tested_file, "reason: $message", $temp_filenames); - junit_mark_test_as('SKIP', $shortname, $tested, null, ""); + junit_mark_test_as('SKIP', $shortname, $tested, null, $message); return 'SKIPPED'; } @@ -2129,7 +2129,7 @@ $output $php = $old_php; } - $diff = empty($diff) ? '' : "', $diff) . "\n]]>"; + $diff = empty($diff) ? '' : preg_replace('/\e/', '', $diff); junit_mark_test_as($restype, str_replace($cwd . '/', '', $tested_file), $tested, null, $info, $diff); @@ -2708,6 +2708,7 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag junit_suite_record($suite, 'execution_time', $time); $escaped_details = htmlspecialchars($details, ENT_QUOTES, 'UTF-8'); + $escaped_message = htmlspecialchars($message, ENT_QUOTES, 'UTF-8'); $escaped_test_name = basename($file_name) . ' - ' . htmlspecialchars($test_name, ENT_QUOTES); $JUNIT['files'][$file_name]['xml'] = "\n"; @@ -2724,16 +2725,16 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag junit_suite_record($suite, 'test_pass'); } elseif ('BORK' == $type) { junit_suite_record($suite, 'test_error'); - $JUNIT['files'][$file_name]['xml'] .= "\n"; + $JUNIT['files'][$file_name]['xml'] .= "\n"; } elseif ('SKIP' == $type) { junit_suite_record($suite, 'test_skip'); - $JUNIT['files'][$file_name]['xml'] .= "$message\n"; + $JUNIT['files'][$file_name]['xml'] .= "$escaped_message\n"; } elseif('FAIL' == $type) { junit_suite_record($suite, 'test_fail'); - $JUNIT['files'][$file_name]['xml'] .= "$escaped_details\n"; + $JUNIT['files'][$file_name]['xml'] .= "$escaped_details\n"; } else { junit_suite_record($suite, 'test_error'); - $JUNIT['files'][$file_name]['xml'] .= "$escaped_details\n"; + $JUNIT['files'][$file_name]['xml'] .= "$escaped_details\n"; } $JUNIT['files'][$file_name]['xml'] .= "\n";