mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-24 22:24:44 +02:00
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:
commit
06403c1147
@ -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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user