diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2018-05-30 17:47:11 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2018-05-30 17:47:11 +0000 |
commit | f4ce54a12390aeaa18ec2b188cb130ea44a8ef14 (patch) | |
tree | fa0543992b2fc78d9599f89ba6a03b47e74f4e73 /llvm/lib/Support/StringExtras.cpp | |
parent | 819f2a20c3fc88d6d396ed54101daa8b69256e47 (diff) | |
download | bcm5719-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.cpp | 17 |
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 << "&"; + 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); |