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.
This commit is contained in:
parent
ed5e4d8be2
commit
82e9291629
|
@ -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, "<0x%hx>", static_cast<unsigned short>(c));
|
||||
}
|
||||
os << buf;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue