summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Beccati <mbeccati@php.net>2014-05-27 11:54:34 +0200
committerMatteo Beccati <mbeccati@php.net>2014-05-27 12:04:52 +0200
commit52705631674a835c2e554bc75a795d92a652623c (patch)
tree86c71c2ea996106aacede6b755837343b4556936
parent4c9f6caf39a0f07b37a3cca033c36de0b7745e6c (diff)
downloadphp-git-52705631674a835c2e554bc75a795d92a652623c.tar.gz
Escape non-printable characters in the junit XML output
XML doesn't allow most of the characters < 0x20 and binary output breaks XML parsers. Such characters are not allowed as entities either, so the generated entities are escaped in order to be printed as text.
-rwxr-xr-xrun-tests.php3
1 files changed, 3 insertions, 0 deletions
diff --git a/run-tests.php b/run-tests.php
index cd57747b2f..1b5bcec253 100755
--- a/run-tests.php
+++ b/run-tests.php
@@ -2708,6 +2708,9 @@ 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_details = preg_replace_callback('/[\0-\x08\x0B\x0C\x0E-\x1F]/', function ($c) {
+ return sprintf('[[0x%02x]]', ord($c[0]));
+ }, $escaped_details);
$escaped_message = htmlspecialchars($message, ENT_QUOTES, 'UTF-8');
$escaped_test_name = basename($file_name) . ' - ' . htmlspecialchars($test_name, ENT_QUOTES);