From 26b37f1792dfaf9b0b30f81e492c8f68b9ece571 Mon Sep 17 00:00:00 2001 From: Anthony Ferrara Date: Fri, 6 Jul 2012 22:37:50 -0400 Subject: [PATCH] Fix two issues with run-tests.php 1. E_STRICT error due to passing return of array_intersect() into reset() directly 2. Details in junit output can produce invalid UTF-8 and XML due to unescaped characters --- run-tests.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/run-tests.php b/run-tests.php index 2a4698639f..302167a6e5 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2668,12 +2668,15 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag $time = null !== $time ? $time : junit_get_timer($file_name); junit_suite_record($suite, 'execution_time', $time); + $escaped_details = htmlspecialchars($details, ENT_QUOTES, 'UTF-8'); + $escaped_test_name = basename($file_name) . ' - ' . htmlspecialchars($test_name, ENT_QUOTES); $JUNIT['files'][$file_name]['xml'] = "\n"; if (is_array($type)) { $output_type = $type[0] . 'ED'; - $type = reset(array_intersect(array('XFAIL', 'FAIL'), $type)); + $temp = array_intersect(array('XFAIL', 'FAIL'), $type); + $type = reset($temp); } else { $output_type = $type . 'ED'; } @@ -2688,10 +2691,10 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag $JUNIT['files'][$file_name]['xml'] .= "$message\n"; } elseif('FAIL' == $type) { junit_suite_record($suite, 'test_fail'); - $JUNIT['files'][$file_name]['xml'] .= "$details\n"; + $JUNIT['files'][$file_name]['xml'] .= "$escaped_details\n"; } else { junit_suite_record($suite, 'test_error'); - $JUNIT['files'][$file_name]['xml'] .= "$details\n"; + $JUNIT['files'][$file_name]['xml'] .= "$escaped_details\n"; } $JUNIT['files'][$file_name]['xml'] .= "\n"; -- 2.49.0