Fix parsing of metadata values containing spaces
This commit is contained in:
parent
150ca971ad
commit
c19b7099b2
1 changed files with 19 additions and 13 deletions
32
src/item.cc
32
src/item.cc
|
|
@ -172,19 +172,7 @@ void item_t::parse_tags(const char * p,
|
|||
q = std::strtok(NULL, " \t")) {
|
||||
const string::size_type len = std::strlen(q);
|
||||
if (len < 2) continue;
|
||||
if (! tag.empty()) {
|
||||
string_map::iterator i;
|
||||
string field(p + (q - buf.get()));
|
||||
if (by_value) {
|
||||
bind_scope_t bound_scope(scope, *this);
|
||||
i = set_tag(tag, expr_t(field).calc(bound_scope), overwrite_existing);
|
||||
} else {
|
||||
i = set_tag(tag, string_value(field), overwrite_existing);
|
||||
}
|
||||
(*i).second.second = true;
|
||||
break;
|
||||
}
|
||||
else if (q[0] == ':' && q[len - 1] == ':') { // a series of tags
|
||||
if (q[0] == ':' && q[len - 1] == ':') { // a series of tags
|
||||
for (char * r = std::strtok(q + 1, ":");
|
||||
r;
|
||||
r = std::strtok(NULL, ":")) {
|
||||
|
|
@ -199,6 +187,24 @@ void item_t::parse_tags(const char * p,
|
|||
index = 2;
|
||||
}
|
||||
tag = string(q, len - index);
|
||||
|
||||
string_map::iterator i;
|
||||
const string::size_type plen = std::strlen(p);
|
||||
const char * v = p + (q - p) + (len - index) + 1;
|
||||
while (*v == '\0' && v < p + plen)
|
||||
++v;
|
||||
|
||||
if (v < p + plen) {
|
||||
string field(v);
|
||||
if (by_value) {
|
||||
bind_scope_t bound_scope(scope, *this);
|
||||
i = set_tag(tag, expr_t(field).calc(bound_scope), overwrite_existing);
|
||||
} else {
|
||||
i = set_tag(tag, string_value(field), overwrite_existing);
|
||||
}
|
||||
(*i).second.second = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue