[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
llvm-svn: 333565
diff --git a/llvm/lib/Support/StringExtras.cpp b/llvm/lib/Support/StringExtras.cpp
index f493315..d8f8ff4 100644
--- a/llvm/lib/Support/StringExtras.cpp
+++ b/llvm/lib/Support/StringExtras.cpp
@@ -68,6 +68,23 @@
}
}
+void llvm::PrintHTMLEscaped(StringRef String, raw_ostream &Out) {
+ for (char C : String) {
+ if (C == '&')
+ Out << "&";
+ else if (C == '<')
+ Out << "<";
+ else if (C == '>')
+ Out << ">";
+ else if (C == '\"')
+ Out << """;
+ else if (C == '\'')
+ Out << "'";
+ else
+ Out << C;
+ }
+}
+
void llvm::printLowerCase(StringRef String, raw_ostream &Out) {
for (const char C : String)
Out << toLower(C);