From eebd8be7466142389f86f673b9398f839062c5fd Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 6 Aug 2015 17:39:46 +0200 Subject: [PATCH] Prevent configuration changes that would break PHP lib ini parser --- library/Icinga/File/Ini/Dom/Section.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library/Icinga/File/Ini/Dom/Section.php b/library/Icinga/File/Ini/Dom/Section.php index 960003394..64779cc62 100644 --- a/library/Icinga/File/Ini/Dom/Section.php +++ b/library/Icinga/File/Ini/Dom/Section.php @@ -3,6 +3,8 @@ namespace Icinga\File\Ini\Dom; +use Icinga\Exception\ConfigurationError; + class Section { /** @@ -33,8 +35,11 @@ class Section public function __construct($name) { $this->name = trim(str_replace("\n", ' ', $name)); + if (false !== strpos($name, ';') || false !== strpos($name, ']')) { + throw new ConfigurationError(sprintf('Ini file error: invalid char in title: %s', $name)); + } if (strlen($this->name) < 1) { - throw new Exception(sprintf('Ini parser error: empty section identifier')); + throw new ConfigurationError(sprintf('Ini file error: empty section identifier')); } }