Skip to content

Commit 40fd858

Browse files
committed
Merge branch 'PHP-5.6'
* PHP-5.6: Fixed broken XML junit output due to escaping of CDATA sections
2 parents 1887f9c + cc3a1af commit 40fd858

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

run-tests.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ function run_test($php, $file, $env)
15361536
}
15371537

15381538
$message = !empty($m[1]) ? $m[1] : '';
1539-
junit_mark_test_as('SKIP', $shortname, $tested, null, "<![CDATA[\n$message\n]]>");
1539+
junit_mark_test_as('SKIP', $shortname, $tested, null, $message);
15401540
return 'SKIPPED';
15411541
}
15421542

@@ -1561,7 +1561,7 @@ function run_test($php, $file, $env)
15611561
) {
15621562
$message = "ext/zlib required";
15631563
show_result('SKIP', $tested, $tested_file, "reason: $message", $temp_filenames);
1564-
junit_mark_test_as('SKIP', $shortname, $tested, null, "<![CDATA[\n$message\n]]>");
1564+
junit_mark_test_as('SKIP', $shortname, $tested, null, $message);
15651565
return 'SKIPPED';
15661566
}
15671567

@@ -2129,7 +2129,7 @@ function run_test($php, $file, $env)
21292129
$php = $old_php;
21302130
}
21312131

2132-
$diff = empty($diff) ? '' : "<![CDATA[\n " . preg_replace('/\e/', '<esc>', $diff) . "\n]]>";
2132+
$diff = empty($diff) ? '' : preg_replace('/\e/', '<esc>', $diff);
21332133

21342134
junit_mark_test_as($restype, str_replace($cwd . '/', '', $tested_file), $tested, null, $info, $diff);
21352135

@@ -2708,6 +2708,7 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag
27082708
junit_suite_record($suite, 'execution_time', $time);
27092709

27102710
$escaped_details = htmlspecialchars($details, ENT_QUOTES, 'UTF-8');
2711+
$escaped_message = htmlspecialchars($message, ENT_QUOTES, 'UTF-8');
27112712

27122713
$escaped_test_name = basename($file_name) . ' - ' . htmlspecialchars($test_name, ENT_QUOTES);
27132714
$JUNIT['files'][$file_name]['xml'] = "<testcase classname='$suite' name='$escaped_test_name' time='$time'>\n";
@@ -2724,16 +2725,16 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag
27242725
junit_suite_record($suite, 'test_pass');
27252726
} elseif ('BORK' == $type) {
27262727
junit_suite_record($suite, 'test_error');
2727-
$JUNIT['files'][$file_name]['xml'] .= "<error type='$output_type' message='$message'/>\n";
2728+
$JUNIT['files'][$file_name]['xml'] .= "<error type='$output_type' message='$escaped_message'/>\n";
27282729
} elseif ('SKIP' == $type) {
27292730
junit_suite_record($suite, 'test_skip');
2730-
$JUNIT['files'][$file_name]['xml'] .= "<skipped>$message</skipped>\n";
2731+
$JUNIT['files'][$file_name]['xml'] .= "<skipped>$escaped_message</skipped>\n";
27312732
} elseif('FAIL' == $type) {
27322733
junit_suite_record($suite, 'test_fail');
2733-
$JUNIT['files'][$file_name]['xml'] .= "<failure type='$output_type' message='$message'>$escaped_details</failure>\n";
2734+
$JUNIT['files'][$file_name]['xml'] .= "<failure type='$output_type' message='$escaped_message'>$escaped_details</failure>\n";
27342735
} else {
27352736
junit_suite_record($suite, 'test_error');
2736-
$JUNIT['files'][$file_name]['xml'] .= "<error type='$output_type' message='$message'>$escaped_details</error>\n";
2737+
$JUNIT['files'][$file_name]['xml'] .= "<error type='$output_type' message='$escaped_message'>$escaped_details</error>\n";
27372738
}
27382739

27392740
$JUNIT['files'][$file_name]['xml'] .= "</testcase>\n";

0 commit comments

Comments
 (0)