summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/StringExtras.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2018-05-30 17:47:11 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2018-05-30 17:47:11 +0000
commitf4ce54a12390aeaa18ec2b188cb130ea44a8ef14 (patch)
treefa0543992b2fc78d9599f89ba6a03b47e74f4e73 /llvm/lib/Support/StringExtras.cpp
parent819f2a20c3fc88d6d396ed54101daa8b69256e47 (diff)
downloadbcm5719-llvm-f4ce54a12390aeaa18ec2b188cb130ea44a8ef14.tar.gz
bcm5719-llvm-f4ce54a12390aeaa18ec2b188cb130ea44a8ef14.zip
[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
Diffstat (limited to 'llvm/lib/Support/StringExtras.cpp')
-rw-r--r--llvm/lib/Support/StringExtras.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Support/StringExtras.cpp b/llvm/lib/Support/StringExtras.cpp
index f4933150d28..d8f8ff4f604 100644
--- a/llvm/lib/Support/StringExtras.cpp
+++ b/llvm/lib/Support/StringExtras.cpp
@@ -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);
OpenPOWER on IntegriCloud