aboutsummaryrefslogtreecommitdiff
path: root/src/torcontrol.cpp
diff options
context:
space:
mode:
authorJack Grigg <[email protected]>2017-03-26 00:35:13 +1300
committerJack Grigg <[email protected]>2017-05-16 18:22:16 +1200
commitd63677bbb23a05feca7935c70673439705b06dca (patch)
treee08db216b94711b65a494f178dc792c7bc69c3ed /src/torcontrol.cpp
parenttorcontrol: Add unit tests for Tor reply parsers (diff)
downloaddiscoin-d63677bbb23a05feca7935c70673439705b06dca.tar.xz
discoin-d63677bbb23a05feca7935c70673439705b06dca.zip
torcontrol: Fix ParseTorReplyMapping
- Ignore remaining input if it is an OptArguments - Correctly handle escapes
Diffstat (limited to 'src/torcontrol.cpp')
-rw-r--r--src/torcontrol.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp
index 2e15c9e73..0d787d16e 100644
--- a/src/torcontrol.cpp
+++ b/src/torcontrol.cpp
@@ -277,17 +277,19 @@ static std::map<std::string,std::string> ParseTorReplyMapping(const std::string
size_t ptr=0;
while (ptr < s.size()) {
std::string key, value;
- while (ptr < s.size() && s[ptr] != '=') {
+ while (ptr < s.size() && s[ptr] != '=' && s[ptr] != ' ') {
key.push_back(s[ptr]);
++ptr;
}
if (ptr == s.size()) // unexpected end of line
return std::map<std::string,std::string>();
+ if (s[ptr] == ' ') // The remaining string is an OptArguments
+ break;
++ptr; // skip '='
if (ptr < s.size() && s[ptr] == '"') { // Quoted string
++ptr; // skip opening '"'
bool escape_next = false;
- while (ptr < s.size() && (!escape_next && s[ptr] != '"')) {
+ while (ptr < s.size() && (escape_next || s[ptr] != '"')) {
escape_next = (s[ptr] == '\\');
value.push_back(s[ptr]);
++ptr;