com php-src: Escape non-printable characters in the junit XML output: run-tests.php

From: Date: Tue, 27 May 2014 10:03:38 +0000
Subject: com php-src: Escape non-printable characters in the junit XML output: run-tests.php
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-78570@lists.php.net to get a copy of this message
Commit: 92d54f81d671f0f14a06fec7bd6f917b085253c6 Author: Matteo Beccati <mbeccati@php.net> Tue, 27 May 2014 11:54:34 +0200 Parents: 1696166466e179c361c562f01a14995a09c41ae3 Branches: PHP-5.4 PHP-5.5 PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=92d54f81d671f0f14a06fec7bd6f917b085253c6 Log: 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. Changed paths: M run-tests.php Diff: diff --git a/run-tests.php b/run-tests.php index c86ebc8..a2f552c 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2701,6 +2701,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);

« previous php.cvs (#78570) next »