mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-25 22:34:27 +00:00
torcontrol: Fix ParseTorReplyMapping
- Ignore remaining input if it is an OptArguments - Correctly handle escapes
This commit is contained in:
parent
29f3c20078
commit
d63677bbb2
@ -277,17 +277,19 @@ static std::map<std::string,std::string> ParseTorReplyMapping(const std::string
|
|||||||
size_t ptr=0;
|
size_t ptr=0;
|
||||||
while (ptr < s.size()) {
|
while (ptr < s.size()) {
|
||||||
std::string key, value;
|
std::string key, value;
|
||||||
while (ptr < s.size() && s[ptr] != '=') {
|
while (ptr < s.size() && s[ptr] != '=' && s[ptr] != ' ') {
|
||||||
key.push_back(s[ptr]);
|
key.push_back(s[ptr]);
|
||||||
++ptr;
|
++ptr;
|
||||||
}
|
}
|
||||||
if (ptr == s.size()) // unexpected end of line
|
if (ptr == s.size()) // unexpected end of line
|
||||||
return std::map<std::string,std::string>();
|
return std::map<std::string,std::string>();
|
||||||
|
if (s[ptr] == ' ') // The remaining string is an OptArguments
|
||||||
|
break;
|
||||||
++ptr; // skip '='
|
++ptr; // skip '='
|
||||||
if (ptr < s.size() && s[ptr] == '"') { // Quoted string
|
if (ptr < s.size() && s[ptr] == '"') { // Quoted string
|
||||||
++ptr; // skip opening '"'
|
++ptr; // skip opening '"'
|
||||||
bool escape_next = false;
|
bool escape_next = false;
|
||||||
while (ptr < s.size() && (!escape_next && s[ptr] != '"')) {
|
while (ptr < s.size() && (escape_next || s[ptr] != '"')) {
|
||||||
escape_next = (s[ptr] == '\\');
|
escape_next = (s[ptr] == '\\');
|
||||||
value.push_back(s[ptr]);
|
value.push_back(s[ptr]);
|
||||||
++ptr;
|
++ptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user