[core] Check type of a convertible value when constructing legacy filter

This commit is contained in:
Alexander Shalamov
2019-08-15 23:01:51 +03:00
parent 8e1bd18eae
commit 5f477e310b
2 changed files with 13 additions and 1 deletions

View File

@@ -195,11 +195,16 @@ ParseResult convertLegacyFilter(const Convertible& values, Error& error) {
return {std::make_unique<Literal>(true)};
}
if (!isArray(values) || arrayLength(values) == 0) {
error.message = "filter value must be a non empty array";
return nullopt;
}
optional<std::string> op = toString(arrayMember(values, 0));
if (!op) {
error.message = "filter operator must be a string";
return {};
return nullopt;
} else if (arrayLength(values) <= 1) {
return {std::make_unique<Literal>(*op != "any")};
} else {