summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-03-02 21:27:50 (GMT)
committerBrad King <brad.king@kitware.com>2009-03-02 21:27:50 (GMT)
commit82e92916290e1079f409687dfbd92131db4bb03d (patch)
treec1feb3b4f58928cead11d850acf0def2e6acae7d
parented5e4d8be2aef9912b8fb7f3af8d9a963318879f (diff)
downloadCMake-82e92916290e1079f409687dfbd92131db4bb03d.zip
CMake-82e92916290e1079f409687dfbd92131db4bb03d.tar.gz
CMake-82e92916290e1079f409687dfbd92131db4bb03d.tar.bz2
BUG: Avoid encoding invalid XML chars in CTest
CTest encodes test and tool output in XML for dashboard submission. This fixes the XML encoding implementation to not encode an invalid character and instead put a human-readable tag in its place. See issue #8647.
-rw-r--r--Source/cmXMLSafe.cxx12
1 files changed, 11 insertions, 1 deletions
diff --git a/Source/cmXMLSafe.cxx b/Source/cmXMLSafe.cxx
index 717743b..eb22063 100644
--- a/Source/cmXMLSafe.cxx
+++ b/Source/cmXMLSafe.cxx
@@ -82,7 +82,17 @@ cmsys_ios::ostream& operator<<(cmsys_ios::ostream& os, cmXMLSafe const& self)
// encoding. Instead of escaping these bytes, we should
// handle the current locale and its encoding.
char buf[16];
- sprintf(buf, "[bad-char-%hx]", static_cast<unsigned short>(c));
+ // http://www.w3.org/TR/REC-xml/#NT-Char
+ if(c >= 0x80)
+ {
+ sprintf(buf, "&#x%hx;", static_cast<unsigned short>(c));
+ }
+ else
+ {
+ // We cannot use "&#x%hx;" here because this value is not
+ // valid in XML. Instead use a human-readable hex value.
+ sprintf(buf, "&lt;0x%hx&gt;", static_cast<unsigned short>(c));
+ }
os << buf;
}
break;