Skip to content

Commit 1bc5318

Browse files
committed
fix: hostname corruption of PSL data
Use multibite strtolower();
1 parent 4da6c1e commit 1bc5318

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Diff for: src/Converter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private function addRule(array $list, array $rule_parts): array
104104
// "The domain and all rules must be canonicalized in the normal way
105105
// for hostnames - lower-case, Punycode (RFC 3492)."
106106

107-
$part = $this->idnToAscii(strtolower($part));
107+
$part = $this->idnToAscii(mb_strtolower($part));
108108
$isDomain = true;
109109
if (0 === strpos($part, '!')) {
110110
$part = substr($part, 1);

Diff for: src/IDNAConverterTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private function setDomain(string $domain = null): array
133133
throw new Exception(sprintf('The domain `%s` is invalid: this is an IPv4 host', $domain));
134134
}
135135

136-
$formatted_domain = strtolower(rawurldecode($domain));
136+
$formatted_domain = mb_strtolower(rawurldecode($domain));
137137

138138
// Note that unreserved is purposely missing . as it is used to separate labels.
139139
static $domain_name = '/(?(DEFINE)

Diff for: src/Manager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private function getCacheKey(string $str): string
8686
{
8787
static $cacheKeyPrefix = 'PSL_FULL';
8888

89-
return $cacheKeyPrefix.'_'.md5(strtolower($str));
89+
return $cacheKeyPrefix.'_'.md5(mb_strtolower($str));
9090
}
9191

9292
/**

0 commit comments

Comments
 (0)