Improve ini editor and dashlet input validation

This commit is contained in:
Matthias Jentsch 2015-08-04 13:23:30 +02:00
parent d88c628b6b
commit 7095ad5bc7
2 changed files with 19 additions and 1 deletions

View File

@ -77,7 +77,21 @@ class DashletForm extends Form
array(
'required' => true,
'label' => $this->translate('Dashlet Title'),
'description' => $this->translate('Enter a title for the dashlet.')
'description' => $this->translate('Enter a title for the dashlet.'),
'validators' => array(
array(
'Regex',
false,
array(
'pattern' => '/^[^\\[\\]]+$/',
'messages' => array(
'regexNotMatch' => $this->translate(
'The name cannot contain \'[\' or \']\'.'
)
)
)
)
)
)
);
$this->addElement(

View File

@ -2,6 +2,7 @@
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
namespace Icinga\File\Ini;
use Icinga\Exception\ConfigurationError;
/**
* Edit the sections and keys of an ini in-place
@ -176,6 +177,9 @@ class IniEditor
*/
public function setSection($section, $extend = null)
{
if (false !== strpos($section, '[') || false !== strpos($section, ']')) {
throw new ConfigurationError('Brackets not allowed in section: %s', $section);
}
if (isset($extend)) {
$decl = '[' . $section . ' : ' . $extend . ']';
} else {