allow single quote for escaping as well (fixes #208)

This commit is contained in:
john30
2018-12-02 13:22:16 +01:00
parent 8ed1e4f151
commit 7d10104dbf
+6 -6
View File
@@ -461,26 +461,26 @@ result_t MainLoop::decodeMessage(const string &data, bool isHttp, bool* connecte
string token, previous;
istringstream stream(data);
vector<string> args;
bool escaped = false;
char escaped = 0;
char delim = ' ';
while (getline(stream, token, delim)) {
if (!isHttp) {
if (escaped) {
args.pop_back();
if (token.length() > 0 && token[token.length()-1] == '"') {
if (token.length() > 0 && token[token.length()-1] == escaped) {
token.erase(token.length() - 1, 1);
escaped = false;
escaped = 0;
}
token = previous + " " + token;
} else if (token.length() == 0) { // allow multiple space chars for a single delimiter
continue;
} else if (token[0] == '"') {
} else if (token[0] == '"' || token[0] == '\'') {
token.erase(0, 1);
if (token.length() > 0 && token[token.length()-1] == '"') {
if (token.length() > 0 && token[token.length()-1] == token[0]) {
token.erase(token.length() - 1, 1);
} else {
escaped = true;
escaped = token[0];
}
}
}