From 7944d3e7f7db37f2bad81b214278d510c094d52a Mon Sep 17 00:00:00 2001 From: Mathieu Tortuyaux Date: Thu, 12 Oct 2023 12:36:02 +0200 Subject: [PATCH] kv-store: support quoted values 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 --- src/update_engine/simple_key_value_store.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/update_engine/simple_key_value_store.cc b/src/update_engine/simple_key_value_store.cc index eb6a952..a814fcc 100644 --- a/src/update_engine/simple_key_value_store.cc +++ b/src/update_engine/simple_key_value_store.cc @@ -27,7 +27,14 @@ map 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; }