Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit f61d12c

Browse files
committed
Merge pull request zendframework#615 from mhujer/zendframeworkgh-612
Zend_Validate_Hostname allows "0" subdomain
2 parents e8164ff + b73d490 commit f61d12c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

library/Zend/Validate/Hostname.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ public function isValid($value)
14591459
$check = 0;
14601460
foreach ($domainParts as $domainPart) {
14611461
// If some domain part is empty (i.e. zend..com), it's invalid
1462-
if (empty($domainPart)) {
1462+
if (empty($domainPart) && $domainPart !== '0') {
14631463
$this->_error(self::INVALID_HOSTNAME);
14641464
return false;
14651465
}

tests/Zend/Validate/HostnameTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,4 +536,14 @@ public function testGermanSmallLetterSharpS()
536536
$validator = new Zend_Validate_Hostname();
537537
$this->assertTrue($validator->isValid('straße.de'));
538538
}
539+
540+
/**
541+
* @group GH-612
542+
*/
543+
public function testZeroSubdomain()
544+
{
545+
$validator = new Zend_Validate_Hostname();
546+
$this->assertTrue($validator->isValid('1.pool.ntp.org'));
547+
$this->assertTrue($validator->isValid('0.pool.ntp.org'));
548+
}
539549
}

0 commit comments

Comments
 (0)