summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Johansson <razze@iki.fi>2020-11-09 08:26:08 +0000
committerRasmus Johansson <razze@iki.fi>2020-11-18 12:31:41 +0000
commitbbbab8215f61ac6aa0af5c4f6a5a8509e9707e68 (patch)
tree17df370bda4e1478237b459c39ec083f8492c28c
parentce0cb6a4f660a2bb4d1cf666f73f62977d03a4e2 (diff)
downloadmariadb-git-bbbab8215f61ac6aa0af5c4f6a5a8509e9707e68.tar.gz
MDEV-24100 Failed to read test report file: Invalid byte 2 of 3-byte UTF-8 sequence.
Explicitly setting encoding to UTF-8 when writing to file and replacing wide characters from MTR_RES_FAILED when writing to XML file. The wide characters are not allowed in XML.
-rw-r--r--mysql-test/lib/mtr_report.pm10
1 files changed, 7 insertions, 3 deletions
diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm
index a58fb369a13..98ed77eea0f 100644
--- a/mysql-test/lib/mtr_report.pm
+++ b/mysql-test/lib/mtr_report.pm
@@ -514,6 +514,10 @@ sub mtr_report_stats ($$$$) {
# if a test case has to be retried it should have the result MTR_RES_FAILED in jUnit XML
if ($test->{'result'} eq "MTR_RES_FAILED" || $test->{'retries'} > 0) {
my $logcontents = $test->{'logfile-failed'} || $test->{'logfile'};
+ # remove any double ] that would end the cdata
+ $logcontents =~ s/]]/\x{fffd}/g;
+ # replace wide characters that aren't allowed in XML 1.0
+ $logcontents =~ s/[\x00-\x08\x0B\x0C\x0E-\x1F]/\x{fffd}/g;
$xml_report .= qq(>\n\t\t\t<failure message="" type="MTR_RES_FAILED">\n<![CDATA[$logcontents]]>\n\t\t\t</failure>\n\t\t</testcase>\n);
} elsif ($test->{'result'} eq "MTR_RES_SKIPPED" && $test->{'disable'}) {
@@ -530,9 +534,9 @@ sub mtr_report_stats ($$$$) {
# save to file
my $xml_file = $::opt_xml_report;
- open XML_FILE, ">", $xml_file or die "Cannot create file $xml_file: $!";
- print XML_FILE $xml_report;
- close XML_FILE;
+ open (my $XML_UFILE, '>:encoding(UTF-8)', $xml_file) or die 'Cannot create file $xml_file: $!';
+ print $XML_UFILE $xml_report;
+ close $XML_UFILE or warn "File close failed!";
}
if (@$extra_warnings)