diff options
author | robocoder <anthon.pang@gmail.com> | 2011-09-04 00:07:08 +0400 |
---|---|---|
committer | robocoder <anthon.pang@gmail.com> | 2011-09-04 00:07:08 +0400 |
commit | 79f6c4ebb727a1f3449c9df6c5859f36964966a2 (patch) | |
tree | 3bd7136fbe6b9ce7e0afcd20aae99d198453c5bd /libs/Zend/Validate | |
parent | 63f46f8ac47793c0f514636d34bbb14aef897317 (diff) |
fixes #2581 - update to ZF 1.11.10
git-svn-id: http://dev.piwik.org/svn/trunk@5123 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'libs/Zend/Validate')
-rw-r--r-- | libs/Zend/Validate/EmailAddress.php | 5 | ||||
-rw-r--r-- | libs/Zend/Validate/Hostname.php | 37 |
2 files changed, 26 insertions, 16 deletions
diff --git a/libs/Zend/Validate/EmailAddress.php b/libs/Zend/Validate/EmailAddress.php index 6cc567daea..48db3e5490 100644 --- a/libs/Zend/Validate/EmailAddress.php +++ b/libs/Zend/Validate/EmailAddress.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: EmailAddress.php 24125 2011-06-07 16:13:26Z adamlundrigan $ + * @version $Id: EmailAddress.php 24304 2011-07-30 01:12:35Z adamlundrigan $ */ /** @@ -527,9 +527,8 @@ class Zend_Validate_EmailAddress extends Zend_Validate_Abstract $this->_setValue($value); // Split email address up and disallow '..' - // and disallow addresses ending with a '.' if ((strpos($value, '..') !== false) or - (!preg_match('/^(.+)@([^@]+[^.])$/', $value, $matches))) { + (!preg_match('/^(.+)@([^@]+)$/', $value, $matches))) { $this->_error(self::INVALID_FORMAT); return false; } diff --git a/libs/Zend/Validate/Hostname.php b/libs/Zend/Validate/Hostname.php index b94e94f6d0..97779239f8 100644 --- a/libs/Zend/Validate/Hostname.php +++ b/libs/Zend/Validate/Hostname.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Hostname.php 23972 2011-05-03 16:26:36Z ralph $ + * @version $Id: Hostname.php 24307 2011-07-30 02:13:14Z adamlundrigan $ */ /** @@ -100,12 +100,12 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract /** * Allows all types of hostnames */ - const ALLOW_ALL = 7; + const ALLOW_URI = 8; /** * Allows all types of hostnames */ - const ALLOW_URI = 8; + const ALLOW_ALL = 15; /** * Array of valid top-level-domains @@ -495,7 +495,6 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract */ public function isValid($value) { - if (!is_string($value)) { $this->_error(self::INVALID); return false; @@ -503,7 +502,6 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract $this->_setValue($value); // Check input against IP address schema - if (preg_match('/^[0-9a-f:.]*$/i', $value) && $this->_options['ip']->setTranslator($this->getTranslator())->isValid($value)) { if (!($this->_options['allow'] & self::ALLOW_IP)) { @@ -521,16 +519,29 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract // necessary to distinguish between the complete domain name and // some local domain. // - // Strip trailing '.' since it is not necessary to validate a non-IP - // hostname. - // // (see ZF-6363) - if (substr($value, -1) === '.') { - $value = substr($value, 0, strlen($value)-1); - } - // Check input against DNS hostname schema + // Local hostnames are allowed to be partitial (ending '.') + if ($this->_options['allow'] & self::ALLOW_LOCAL) { + if (substr($value, -1) === '.') { + $value = substr($value, 0, -1); + if (substr($value, -1) === '.') { + // Empty hostnames (ending '..') are not allowed + $this->_error(self::INVALID_LOCAL_NAME); + return false; + } + } + } + $domainParts = explode('.', $value); + + // Prevent partitial IP V4 adresses (ending '.') + if ((count($domainParts) == 4) && preg_match('/^[0-9.a-e:.]*$/i', $value) && + $this->_options['ip']->setTranslator($this->getTranslator())->isValid($value)) { + $this->_error(self::INVALID_LOCAL_NAME); + } + + // Check input against DNS hostname schema if ((count($domainParts) > 1) && (strlen($value) >= 4) && (strlen($value) <= 254)) { $status = false; @@ -651,7 +662,7 @@ class Zend_Validate_Hostname extends Zend_Validate_Abstract } // Check input against local network name schema; last chance to pass validation - $regexLocal = '/^(([a-zA-Z0-9\x2d]{1,63}\x2e)*[a-zA-Z0-9\x2d]{1,63}){1,254}$/'; + $regexLocal = '/^(([a-zA-Z0-9\x2d]{1,63}\x2e)*[a-zA-Z0-9\x2d]{1,63}[\x2e]{0,1}){1,254}$/'; $status = @preg_match($regexLocal, $value); // If the input passes as a local network name, and local network names are allowed, then the |