From ef5d0b5e97ec8e6fa395d377b09aa7755e345b4f Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 18 Dec 2017 20:12:36 +0000 Subject: Vendor import of lldb trunk r321017: https://llvm.org/svn/llvm-project/lldb/trunk@321017 --- source/Utility/JSON.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/Utility/JSON.cpp') diff --git a/source/Utility/JSON.cpp b/source/Utility/JSON.cpp index 1520bc7c47ec..9049f596ab9a 100644 --- a/source/Utility/JSON.cpp +++ b/source/Utility/JSON.cpp @@ -22,7 +22,7 @@ using namespace lldb_private; std::string JSONString::json_string_quote_metachars(const std::string &s) { - if (s.find('"') == std::string::npos) + if (s.find_first_of("\\\n\"") == std::string::npos) return s; std::string output; @@ -30,8 +30,9 @@ std::string JSONString::json_string_quote_metachars(const std::string &s) { const char *s_chars = s.c_str(); for (size_t i = 0; i < s_size; i++) { unsigned char ch = *(s_chars + i); - if (ch == '"') { + if (ch == '"' || ch == '\\' || ch == '\n') { output.push_back('\\'); + if (ch == '\n') ch = 'n'; } output.push_back(ch); } -- cgit v1.3