diff --git a/src/Task.cpp b/src/Task.cpp index c0adcc36b..31c3125bb 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -659,17 +659,18 @@ void Task::parse (const std::string& input) data[name] = decode (json::decode (value)); // Fix for issue#2689: taskserver sometimes encodes the depends - // property as a JSON-encoded one-element array of strings. So, if - // depends has form `[".."]`, then apply another layer of JSON - // decoding. - if (name == "depends" && data[name].length () >= 4) { - auto l = data[name].length (); - if (data[name][0] == '[' && - data[name][1] == '"' && - data[name][l-2] == '"' && - data[name][l-1] == ']') { - data[name] = data[name].substr(2, l-4); + // property as a JSON-encoded array of strings. To avoid this whole + // issue, we strip anything that isn't a UUID character or a comma. + if (name == "depends") { + std::string newDep; + for (auto &c: data[name]) { + if ((c >= '0' && c <= '9') || + (c >= 'a' && c <= 'f') || + c == ',' || c == '-') { + newDep.push_back(c); + } } + data[name] = newDep; } } diff --git a/test/t.t.cpp b/test/t.t.cpp index 484e5f3d7..d053f0643 100644 --- a/test/t.t.cpp +++ b/test/t.t.cpp @@ -137,7 +137,7 @@ int main (int, char**) sample = "[" "uuid:\"00000000-0000-0000-0000-000000000000\" " "description:\"d\" " - "depends:\"[\\\"cfee3170-f153-4075-aa1d-e20bcac2841b,f5982cca-2ea1-4bfd-832c-9bd571dc0743\\\"]\"" + "depends:\"[\\\"cfee3170-f153-4075-aa1d-e20bcac2841b\\\",\\\"f5982cca-2ea1-4bfd-832c-9bd571dc0743\\\"]\"" "]"; ff4 = Task (sample); value = ff4.get ("uuid"); @@ -151,7 +151,7 @@ int main (int, char**) sample = "[" "uuid:\"00000000-0000-0000-0000-000000000000\" " "description:\"d\" " - "depends:\"&open;\\\"cfee3170-f153-4075-aa1d-e20bcac2841b,f5982cca-2ea1-4bfd-832c-9bd571dc0743\\\"&close;\"" + "depends:\"&open;\\\"cfee3170-f153-4075-aa1d-e20bcac2841b\\\",\\\"f5982cca-2ea1-4bfd-832c-9bd571dc0743\\\"&close;\"" "]"; ff4 = Task (sample); value = ff4.get ("uuid");