diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:12:36 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:12:36 +0000 |
commit | ef5d0b5e97ec8e6fa395d377b09aa7755e345b4f (patch) | |
tree | 27916256fdeeb57d10d2f3d6948be5d71a703215 /source/Utility/JSON.cpp | |
parent | 76e0736e7fcfeb179779e49c05604464b1ccd704 (diff) |
Notes
Diffstat (limited to 'source/Utility/JSON.cpp')
-rw-r--r-- | source/Utility/JSON.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/source/Utility/JSON.cpp b/source/Utility/JSON.cpp index 1520bc7c47ec7..9049f596ab9a5 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); } |