Improve ini editor and dashlet input validation
This commit is contained in:
parent
d88c628b6b
commit
7095ad5bc7
|
@ -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(
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue