Skip to content

Commit

Permalink
Escape invalid XML chars in testCase and testSuite names
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-abalik committed Jul 24, 2024
1 parent 2393517 commit a1b26c9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void toXml(XMLStreamWriter xml, TestData test) throws XMLStreamException
}

xml.writeStartElement("testcase");
xml.writeAttribute("name", name);
xml.writeAttribute("name", escapeIllegalCharacters(name));
xml.writeAttribute("classname", LegacyReportingUtils.getClassName(testPlan, id));

/* @Nullable */ Duration maybeDuration = test.getDuration();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.bazel_contrib.contrib_rules_jvm.junit5;

import static com.github.bazel_contrib.contrib_rules_jvm.junit5.SafeXml.escapeIllegalCharacters;
import static com.github.bazel_contrib.contrib_rules_jvm.junit5.SafeXml.writeTextElement;

import java.util.Collection;
Expand All @@ -19,7 +20,7 @@ public void toXml(XMLStreamWriter xml, TestData suite, Collection<TestData> test
throws XMLStreamException {
xml.writeStartElement("testsuite");

xml.writeAttribute("name", suite.getId().getLegacyReportingName());
xml.writeAttribute("name", escapeIllegalCharacters(suite.getId().getLegacyReportingName()));
xml.writeAttribute("tests", String.valueOf(tests.size()));

int errors = 0;
Expand Down

0 comments on commit a1b26c9

Please sign in to comment.