Prevent configuration changes that would break PHP lib ini parser

This commit is contained in:
Matthias Jentsch 2015-08-06 17:39:46 +02:00
parent 9b373e9d10
commit eebd8be746
1 changed files with 6 additions and 1 deletions

View File

@ -3,6 +3,8 @@
namespace Icinga\File\Ini\Dom; namespace Icinga\File\Ini\Dom;
use Icinga\Exception\ConfigurationError;
class Section class Section
{ {
/** /**
@ -33,8 +35,11 @@ class Section
public function __construct($name) public function __construct($name)
{ {
$this->name = trim(str_replace("\n", ' ', $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) { 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'));
} }
} }