when processing quoted strings, the quotes need to be removed
This commit is contained in:
@ -436,6 +436,7 @@ std::vector<std::string> utils::split_words(const std::string &text)
|
||||
const char *buf = text.c_str();
|
||||
std::size_t beg = 0;
|
||||
std::size_t len = 0;
|
||||
std::size_t add = 0;
|
||||
char c = *buf;
|
||||
|
||||
while (c) {
|
||||
@ -452,8 +453,9 @@ std::vector<std::string> utils::split_words(const std::string &text)
|
||||
|
||||
// handle single quote
|
||||
if (c == '\'') {
|
||||
++beg;
|
||||
add = 1;
|
||||
c = *++buf;
|
||||
++len;
|
||||
while (((c != '\'') && (c != '\0'))
|
||||
|| ((c == '\\') && (buf[1] == '\''))) {
|
||||
if ((c == '\\') && (buf[1] == '\'')) {
|
||||
@ -463,13 +465,14 @@ std::vector<std::string> utils::split_words(const std::string &text)
|
||||
c = *++buf;
|
||||
++len;
|
||||
}
|
||||
if (c != '\'') ++len;
|
||||
c = *++buf;
|
||||
++len;
|
||||
|
||||
// handle double quote
|
||||
} else if (c == '"') {
|
||||
++beg;
|
||||
add = 1;
|
||||
c = *++buf;
|
||||
++len;
|
||||
while (((c != '"') && (c != '\0'))
|
||||
|| ((c == '\\') && (buf[1] == '"'))) {
|
||||
if ((c == '\\') && (buf[1] == '"')) {
|
||||
@ -479,8 +482,8 @@ std::vector<std::string> utils::split_words(const std::string &text)
|
||||
c = *++buf;
|
||||
++len;
|
||||
}
|
||||
if (c != '"') ++len;
|
||||
c = *++buf;
|
||||
++len;
|
||||
}
|
||||
|
||||
// unquoted
|
||||
@ -496,7 +499,7 @@ std::vector<std::string> utils::split_words(const std::string &text)
|
||||
if ((c == ' ') || (c == '\t') || (c == '\r') || (c == '\n')
|
||||
|| (c == '\f') || (c == '\0')) {
|
||||
list.push_back(text.substr(beg,len));
|
||||
beg += len;
|
||||
beg += len + add;
|
||||
break;
|
||||
}
|
||||
c = *++buf;
|
||||
|
||||
Reference in New Issue
Block a user