diff --git a/application/forms/Dashboard/DashletForm.php b/application/forms/Dashboard/DashletForm.php index f3df2c216..9b23d9517 100644 --- a/application/forms/Dashboard/DashletForm.php +++ b/application/forms/Dashboard/DashletForm.php @@ -3,10 +3,11 @@ namespace Icinga\Forms\Dashboard; -use Icinga\Web\Widget\Dashboard; use Icinga\Web\Form; +use Icinga\Web\Form\Validator\InternalUrlValidator; use Icinga\Web\Form\Validator\UrlValidator; use Icinga\Web\Url; +use Icinga\Web\Widget\Dashboard; use Icinga\Web\Widget\Dashboard\Dashlet; /** @@ -70,7 +71,7 @@ class DashletForm extends Form 'description' => $this->translate( 'Enter url being loaded in the dashlet. You can paste the full URL, including filters.' ), - 'validators' => array(new UrlValidator()) + 'validators' => array(new UrlValidator(), new InternalUrlValidator()) ) ); $this->addElement( diff --git a/library/Icinga/Web/Form/Validator/InternalUrlValidator.php b/library/Icinga/Web/Form/Validator/InternalUrlValidator.php new file mode 100644 index 000000000..07726824a --- /dev/null +++ b/library/Icinga/Web/Form/Validator/InternalUrlValidator.php @@ -0,0 +1,39 @@ +isExternal()) { + $this->_error('IS_EXTERNAL'); + + return false; + } + + return true; + } + + /** + * {@inheritdoc} + */ + protected function _error($messageKey, $value = null) + { + if ($messageKey === 'IS_EXTERNAL') { + $this->_messages[$messageKey] = t('The url must not be external.'); + } else { + parent::_error($messageKey, $value); + } + } +}