Skip to content

Commit

Permalink
kv-store: support quoted values
Browse files Browse the repository at this point in the history
In the case of the value contains whitespaces, it has to be surrounded
with quotes (single or double).

We should exclude these characters from the final values.

Signed-off-by: Mathieu Tortuyaux <[email protected]>
  • Loading branch information
tormath1 committed Oct 12, 2023
1 parent 876d354 commit 7944d3e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/update_engine/simple_key_value_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ map<std::string, std::string> ParseString(const string& str) {
string::size_type pos = it->find('=');
if (pos == string::npos)
continue;
ret[it->substr(0, pos)] = it->substr(pos + 1);
string val = it->substr(pos + 1);
if ((val.length() > 2) &&
((val.at(0) == '\"' && val.at(val.length() - 1) == '\"') ||
(val.at(0) == '\'' && val.at(val.length() - 1) == '\''))) {
val = val.substr(1, val.length() - 2);
}

ret[it->substr(0, pos)] = val;
}
return ret;
}
Expand Down

0 comments on commit 7944d3e

Please sign in to comment.