From 31fca0f676d42fb7ad0318c8702e1562dd627295 Mon Sep 17 00:00:00 2001 From: Michael Keller Date: Fri, 14 Jun 2024 21:05:30 +1200 Subject: [PATCH] Filter: Fix Loading of Negated Conditions from git. Fix loading of the negation of filter conditions. Unlike other conditions that are persisted as `=""`, this is persisted to git as `negate`. This fix remediates this for all cases where the condition has already been saved to the cloud storage. Saving to XML takes a different approach and indicates negated conditions with `negate="1"`, making it identical to all other attributes. The question is if this approach should be implemented in addition to the above fix, in order to unify the storage format. Fixes #4246. Signed-off-by: Michael Keller --- core/load-git.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/core/load-git.cpp b/core/load-git.cpp index 75af6cba7..ba25794e1 100644 --- a/core/load-git.cpp +++ b/core/load-git.cpp @@ -357,23 +357,27 @@ static char *parse_keyvalue_entry(void (*fn)(void *, const char *, const std::st line++; } - if (c == '=') + if (c != 0) *line++ = 0; - char *start_val = line; - while ((c = *line) != 0) { - if (isspace(c)) - break; - line++; + std::string val; + if (c == '=') { + const char *start_val = line; + while ((c = *line) != 0) { + if (isspace(c)) + break; + line++; + } + + /* Did we get a string? Take it from the list of strings */ + val = start_val[0] == '"' ? pop_cstring(state, key) + : std::string(start_val, line - start_val); + + if (c) + line++; + } - /* Did we get a string? Take it from the list of strings */ - std::string val = start_val[0] == '"' ? pop_cstring(state, key) - : std::string(start_val, line - start_val); - - if (c) - line++; - fn(fndata, key, val); return line; }