[dsymutil] Escape HTML special characters in plist.

When printing string in the Plist, we weren't escaping the characters
which lead to invalid XML. This patch adds the escape logic to
StringExtras.

rdar://39785334

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333565 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jonas Devlieghere
2018-05-30 17:47:11 +00:00
parent 21cf02e060
commit e22dca5286
4 changed files with 40 additions and 10 deletions
+17
View File
@@ -68,6 +68,23 @@ void llvm::PrintEscapedString(StringRef Name, raw_ostream &Out) {
}
}
void llvm::PrintHTMLEscaped(StringRef String, raw_ostream &Out) {
for (char C : String) {
if (C == '&')
Out << "&amp;";
else if (C == '<')
Out << "&lt;";
else if (C == '>')
Out << "&gt;";
else if (C == '\"')
Out << "&quot;";
else if (C == '\'')
Out << "&apos;";
else
Out << C;
}
}
void llvm::printLowerCase(StringRef String, raw_ostream &Out) {
for (const char C : String)
Out << toLower(C);