Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 9adc62f

Browse files
committed
Merge branch 'hotfix/241'
Close #241 Fixes #240
2 parents fdaedea + 6f97afe commit 9adc62f

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5-
## 2.10.3 - TBD
5+
## 2.10.3 - 2018-12-13
66

77
### Added
88

@@ -22,6 +22,9 @@ All notable changes to this project will be documented in this file, in reverse
2222

2323
### Fixed
2424

25+
- [#241](https://github.com/zendframework/zend-validator/pull/241) has the `Hostname` validator return an invalid result early when an empty
26+
domain segment is detected.
27+
2528
- [#232](https://github.com/zendframework/zend-validator/pull/232) updates the `Hostname` validator to allow underscores in subdomains.
2629

2730
- [#218](https://github.com/zendframework/zend-validator/pull/218) fixes a precision issue with the `Step` validator.

src/Hostname.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,6 +2092,13 @@ public function isValid($value)
20922092
}
20932093
}
20942094

2095+
// Skip following checks if domain part is empty, as it definitely is not a valid hostname then
2096+
if ($domainPart === '') {
2097+
$this->error(self::INVALID_HOSTNAME);
2098+
$status = false;
2099+
break 2;
2100+
}
2101+
20952102
// Check dash (-) does not start, end or appear in 3rd and 4th positions
20962103
if ($utf8StrWrapper->strpos($domainPart, '-') === 0
20972104
|| ($utf8StrWrapper->strlen($domainPart) > 2

test/HostnameTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,4 +701,10 @@ public function testValidBizHostname()
701701
$validator = new Hostname();
702702
$this->assertTrue($validator->isValid('google.biz'));
703703
}
704+
705+
public function testHostnameWithEmptyDomainPart()
706+
{
707+
$validator = new Hostname();
708+
$this->assertFalse($validator->isValid('.com'));
709+
}
704710
}

0 commit comments

Comments
 (0)