aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-07-15 01:13:26 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-07-15 01:13:26 +0000
commit89a48cbd1fd24590bd56369a3f9fb10069db2fd5 (patch)
tree20ea9a3675e9c809d5809e3ef6095b12fd977cfd
parent31124fac8ac399e6991fb73bc25ba6cfc26d432c (diff)
parent6a85ad2bf698225d31732a343341c1787e30b451 (diff)
downloadtradefederation-android11-security-release.tar.gz
Change-Id: I983406ca2c07822d326dab14872b624bc1f6bd9b
-rw-r--r--src/com/android/tradefed/result/suite/XmlSuiteResultFormatter.java4
-rw-r--r--tests/src/com/android/tradefed/result/suite/XmlSuiteResultFormatterTest.java8
2 files changed, 6 insertions, 6 deletions
diff --git a/src/com/android/tradefed/result/suite/XmlSuiteResultFormatter.java b/src/com/android/tradefed/result/suite/XmlSuiteResultFormatter.java
index 06592b2ef..772075b6b 100644
--- a/src/com/android/tradefed/result/suite/XmlSuiteResultFormatter.java
+++ b/src/com/android/tradefed/result/suite/XmlSuiteResultFormatter.java
@@ -34,6 +34,7 @@ import com.android.tradefed.util.StreamUtil;
import com.android.tradefed.util.proto.TfMetricProtoUtil;
import com.google.common.base.Strings;
+import com.google.common.xml.XmlEscapers;
import com.google.gson.Gson;
import org.xmlpull.v1.XmlPullParser;
@@ -707,7 +708,6 @@ public class XmlSuiteResultFormatter implements IFormatterGenerator {
@VisibleForTesting
static String sanitizeXmlContent(String s) {
- // Replace c++ \0 null since Serializer doesn't handle it.
- return s.replace("\0", "[Null]");
+ return XmlEscapers.xmlContentEscaper().escape(s);
}
}
diff --git a/tests/src/com/android/tradefed/result/suite/XmlSuiteResultFormatterTest.java b/tests/src/com/android/tradefed/result/suite/XmlSuiteResultFormatterTest.java
index 67a623a5c..647db0b7e 100644
--- a/tests/src/com/android/tradefed/result/suite/XmlSuiteResultFormatterTest.java
+++ b/tests/src/com/android/tradefed/result/suite/XmlSuiteResultFormatterTest.java
@@ -170,7 +170,7 @@ public class XmlSuiteResultFormatterTest {
assertXmlContainsValue(
content,
"Result/Module/TestCase/Test/Failure/StackTrace",
- "module1 failed.\nstack\n<null>stack[Null]");
+ XmlSuiteResultFormatter.sanitizeXmlContent("module1 failed.\nstack\nstack\0"));
// Test that we can read back the informations
SuiteResultHolder holder = mFormatter.parseResults(mResultDir, false);
assertEquals(holder.completeModules, mResultHolder.completeModules);
@@ -224,7 +224,7 @@ public class XmlSuiteResultFormatterTest {
assertXmlContainsValue(
content,
"Result/Module/TestCase/Test/Failure/StackTrace",
- "module1 failed.\nstack\n<null>stack[Null]");
+ XmlSuiteResultFormatter.sanitizeXmlContent("module1 failed.\nstack\nstack\0"));
// Test that we can read back the informations
SuiteResultHolder holder = mFormatter.parseResults(mResultDir, false);
assertEquals(holder.completeModules, mResultHolder.completeModules);
@@ -477,7 +477,7 @@ public class XmlSuiteResultFormatterTest {
assertXmlContainsValue(
content,
"Result/Module/TestCase/Test/Failure/StackTrace",
- "module1 failed.\nstack\n<null>stack[Null]");
+ XmlSuiteResultFormatter.sanitizeXmlContent("module1 failed.\nstack\nstack\0"));
// Test that we can read back the informations
SuiteResultHolder holder = mFormatter.parseResults(mResultDir, true);
assertEquals(holder.completeModules, mResultHolder.completeModules);
@@ -671,7 +671,7 @@ public class XmlSuiteResultFormatterTest {
new TestDescription("com.class." + runName, runName + ".failed" + i);
fakeRes.testStarted(description);
// Include a null character \0 that is not XML supported
- fakeRes.testFailed(description, runName + " failed.\nstack\n<null>stack\0");
+ fakeRes.testFailed(description, runName + " failed.\nstack\nstack\0");
HashMap<String, Metric> metrics = new HashMap<String, Metric>();
if (withMetrics) {
metrics.put("metric0" + i, TfMetricProtoUtil.stringToMetric("value0" + i));