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 | llvm-f4ce54a12390aeaa18ec2b188cb130ea44a8ef14.zip llvm-f4ce54a12390aeaa18ec2b188cb130ea44a8ef14.tar.gz llvm-f4ce54a12390aeaa18ec2b188cb130ea44a8ef14.tar.bz2 |
[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 f493315..d8f8ff4 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); |