From 410b04439631458795eb8e6df55249954785372a Mon Sep 17 00:00:00 2001 From: Thomas Barber Date: Wed, 9 Aug 2023 12:25:11 +0000 Subject: [PATCH] Escape control chars in XML test report creation --- testing/mozbase/mozlog/mozlog/formatters/xunit.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testing/mozbase/mozlog/mozlog/formatters/xunit.py b/testing/mozbase/mozlog/mozlog/formatters/xunit.py index 02966d713aaec..ac08be265eb32 100644 --- a/testing/mozbase/mozlog/mozlog/formatters/xunit.py +++ b/testing/mozbase/mozlog/mozlog/formatters/xunit.py @@ -4,6 +4,7 @@ from xml.etree import ElementTree +import re import six from . import base @@ -109,6 +110,8 @@ def suite_end(self, data): } ) xml_string = ElementTree.tostring(self.root, encoding="utf8") + # Need to remove control characters as they confuse minidom + xml_string = re.sub(r'[\x00-\x1F]+', '', xml_string.decode()) # pretty printing can not be done from xml.etree from xml.dom import minidom