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

Commit ab31167

Browse files
committed
Punycoded TLD to ASCII
1 parent fa0b74f commit ab31167

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Hostname.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1772,8 +1772,16 @@ public function isValid($value)
17721772
// id-prefix: alpha / digit
17731773
// ldh: alpha / digit / dash
17741774

1775-
// Match TLD against known list
17761775
$this->tld = strtoupper($matches[1]);
1776+
// Decode Punycode TLD to IDN
1777+
if (strpos($this->tld, 'xn--') === 0) {
1778+
$this->tld = $this->decodePunycode(substr($this->tld, 4));
1779+
if ($this->tld === false) {
1780+
return false;
1781+
}
1782+
}
1783+
1784+
// Match TLD against known list
17771785
if ($this->getTldCheck()) {
17781786
if (!in_array(strtolower($this->tld), $this->validTlds)
17791787
&& !in_array($this->tld, $this->validTlds)) {

0 commit comments

Comments
 (0)