From b7bdf2e8d40972c3fd429e34db1184d9a62cb8ca Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 23 Feb 2016 13:13:06 +0100 Subject: [PATCH] Implement UrlValidator --- .../Web/Form/Validator/UrlValidator.php | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 library/Icinga/Web/Form/Validator/UrlValidator.php diff --git a/library/Icinga/Web/Form/Validator/UrlValidator.php b/library/Icinga/Web/Form/Validator/UrlValidator.php new file mode 100644 index 000000000..2fd882446 --- /dev/null +++ b/library/Icinga/Web/Form/Validator/UrlValidator.php @@ -0,0 +1,41 @@ + 'The url must not contain raw double quotes. If you really need double quotes, use %22 instead.' + ); + + /** + * Validate the input value + * + * @param string $value The string to validate + * + * @return bool true if and only if the input is valid, otherwise false + * + * @see Zend_Validate_Abstract::isValid() + */ + public function isValid($value) + { + $hasQuotes = false === strpos($value, '"'); + if (! $hasQuotes) { + $this->_error('HAS_QUOTES'); + } + return $hasQuotes; + } +}