allow single quote for escaping as well (fixes #208)
This commit is contained in:
@@ -461,26 +461,26 @@ result_t MainLoop::decodeMessage(const string &data, bool isHttp, bool* connecte
|
|||||||
string token, previous;
|
string token, previous;
|
||||||
istringstream stream(data);
|
istringstream stream(data);
|
||||||
vector<string> args;
|
vector<string> args;
|
||||||
bool escaped = false;
|
char escaped = 0;
|
||||||
|
|
||||||
char delim = ' ';
|
char delim = ' ';
|
||||||
while (getline(stream, token, delim)) {
|
while (getline(stream, token, delim)) {
|
||||||
if (!isHttp) {
|
if (!isHttp) {
|
||||||
if (escaped) {
|
if (escaped) {
|
||||||
args.pop_back();
|
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);
|
token.erase(token.length() - 1, 1);
|
||||||
escaped = false;
|
escaped = 0;
|
||||||
}
|
}
|
||||||
token = previous + " " + token;
|
token = previous + " " + token;
|
||||||
} else if (token.length() == 0) { // allow multiple space chars for a single delimiter
|
} else if (token.length() == 0) { // allow multiple space chars for a single delimiter
|
||||||
continue;
|
continue;
|
||||||
} else if (token[0] == '"') {
|
} else if (token[0] == '"' || token[0] == '\'') {
|
||||||
token.erase(0, 1);
|
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);
|
token.erase(token.length() - 1, 1);
|
||||||
} else {
|
} else {
|
||||||
escaped = true;
|
escaped = token[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user