From e11feb81f5ab0f966831a5e127698e615a57a295 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 12 Mar 2020 13:53:30 +0100 Subject: [PATCH] Don't fail with an exception if module.info is flawed --- library/Icinga/Application/Modules/Module.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index 5290f7283..9bf3d8f30 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -860,7 +860,7 @@ class Module if (file_exists($this->metadataFile)) { $key = null; $file = new File($this->metadataFile, 'r'); - foreach ($file as $line) { + foreach ($file as $lineno => $line) { $line = rtrim($line); if ($key === 'description') { @@ -875,6 +875,19 @@ class Module continue; } + if (strpos($line, ':') === false) { + Logger::debug( + $this->translate( + "Can't process line %d in %s: Line does not specify a key:value pair" + . " nor is it part of the description (indented with a single space)" + ), + $lineno, + $this->metadataFile + ); + + break; + } + list($key, $val) = preg_split('/:\s+/', $line, 2); $key = lcfirst($key);