|
6 | 6 | * @subpackage League\Uri\PublicSuffix |
7 | 7 | * @author Ignace Nyamagana Butera <nyamsprod@gmail.com> |
8 | 8 | * @license https://github.com/thephpleague/uri-hostname-parser/blob/master/LICENSE (MIT License) |
9 | | - * @version 1.0.2 |
| 9 | + * @version 1.0.3 |
10 | 10 | * @link https://github.com/thephpleague/uri-hostname-parser |
11 | 11 | * |
12 | 12 | * For the full copyright and license information, please view the LICENSE |
@@ -84,7 +84,16 @@ private function isMatchable($domain): bool |
84 | 84 | */ |
85 | 85 | private function normalize(string $domain): string |
86 | 86 | { |
87 | | - return strtolower(idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46)); |
| 87 | + if (false !== strpos($domain, '%')) { |
| 88 | + $domain = rawurldecode($domain); |
| 89 | + } |
| 90 | + |
| 91 | + $normalize = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); |
| 92 | + if (false === $normalize) { |
| 93 | + return ''; |
| 94 | + } |
| 95 | + |
| 96 | + return strtolower($normalize); |
88 | 97 | } |
89 | 98 |
|
90 | 99 | /** |
@@ -168,8 +177,12 @@ private function handleNoMatches(string $domain): Domain |
168 | 177 | { |
169 | 178 | $labels = explode('.', $domain); |
170 | 179 | $publicSuffix = array_pop($labels); |
171 | | - if (null !== $publicSuffix && !$this->isPunycoded($domain)) { |
| 180 | + |
| 181 | + if (!$this->isPunycoded($domain)) { |
172 | 182 | $publicSuffix = idn_to_utf8($publicSuffix, 0, INTL_IDNA_VARIANT_UTS46); |
| 183 | + if (false === $publicSuffix) { |
| 184 | + $publicSuffix = null; |
| 185 | + } |
173 | 186 | } |
174 | 187 |
|
175 | 188 | return new Domain($domain, $publicSuffix); |
|
0 commit comments