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
1 changed files with 9 additions and 0 deletions

View File

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