Merge pull request #5635 from Icinga/fix/match-with-empty-array

Fix match(), regex(), cidr_match() behaviour with MatchAll and empty arrays
This commit is contained in:
Michael Friedrich 2017-10-10 17:46:51 +02:00 committed by GitHub
commit 06403c1147

View File

@ -128,6 +128,9 @@ bool ScriptUtils::Regex(const std::vector<Value>& args)
texts->Add(argTexts); texts->Add(argTexts);
} }
if (texts->GetLength() == 0)
return false;
ObjectLock olock(texts); ObjectLock olock(texts);
for (const String& text : texts) { for (const String& text : texts) {
bool res = false; bool res = false;
@ -171,6 +174,9 @@ bool ScriptUtils::Match(const std::vector<Value>& args)
texts->Add(argTexts); texts->Add(argTexts);
} }
if (texts->GetLength() == 0)
return false;
ObjectLock olock(texts); ObjectLock olock(texts);
for (const String& text : texts) { for (const String& text : texts) {
bool res = Utility::Match(pattern, text); bool res = Utility::Match(pattern, text);
@ -207,6 +213,9 @@ bool ScriptUtils::CidrMatch(const std::vector<Value>& args)
ips->Add(argIps); ips->Add(argIps);
} }
if (ips->GetLength() == 0)
return false;
ObjectLock olock(ips); ObjectLock olock(ips);
for (const String& ip : ips) { for (const String& ip : ips) {
bool res = Utility::CidrMatch(pattern, ip); bool res = Utility::CidrMatch(pattern, ip);