Sanitize text before emitting to XML.
This is the absolute least amount of sanitization that will work.
I'll consider adding more as necessary; currently I'm not too
interested in spending the time to make this perfect.
diff --git a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/XmlReportPrinter.java b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/XmlReportPrinter.java
index bc3c507..bfea0bc 100644
--- a/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/XmlReportPrinter.java
+++ b/libcore/tools/dalvik_jtreg/java/dalvik/jtreg/XmlReportPrinter.java
@@ -187,11 +187,19 @@
serializer.attribute(ns, ATTR_MESSAGE, title);
}
serializer.attribute(ns, ATTR_TYPE, testRun.getResult().toString());
- serializer.text(Strings.join(testRun.getOutputLines(), "\n"));
+ String text = sanitize(Strings.join(testRun.getOutputLines(), "\n"));
+ serializer.text(text);
serializer.endTag(ns, result);
}
serializer.endTag(ns, TESTCASE);
}
+
+ /**
+ * Returns the text in a format that is safe for use in an XML document.
+ */
+ private String sanitize(String text) {
+ return text.replace("\0", "<\\0>");
+ }
}
}
\ No newline at end of file