diff --git a/.github/scripts/junit.py b/.github/scripts/junit.py
index 2c63efe0be83..4864c45196a2 100644
--- a/.github/scripts/junit.py
+++ b/.github/scripts/junit.py
@@ -23,6 +23,7 @@
import sys
from typing import Tuple, Optional, List, Iterable
import xml.etree.ElementTree
+import html
logger = logging.getLogger()
@@ -99,6 +100,9 @@ def parse_report(workspace_path, report_path, fp) -> Iterable[TestSuite]:
test_case_failed = False
elif elem.tag == "failure":
failure_message = elem.get("message")
+ if failure_message:
+ failure_message = html.escape(failure_message)
+ failure_message = failure_message.replace('\n', '
').replace('\r', '
')
failure_class = elem.get("type")
failure_stack_trace = elem.text
failure = partial_test_case(failure_message, failure_class, failure_stack_trace)