Prevent configuration changes that would break PHP lib ini parser
This commit is contained in:
parent
9b373e9d10
commit
eebd8be746
|
@ -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'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue