MDL-75889 core: compare domain names in a case-insensitive manner.

As per https://www.rfc-editor.org/rfc/rfc1035#section-3.1
This commit is contained in:
Paul Holden 2022-10-04 21:28:33 +01:00
parent fee1b8ce5f
commit c4c823c20e
3 changed files with 15 additions and 6 deletions

View file

@ -187,8 +187,8 @@ final class ip_utils {
}
/**
* Checks the domain name against a list of allowed domains. The list of allowed domains is may use
* wildcards that match {@link is_domain_matching_pattern()}.
* Checks the domain name against a list of allowed domains. The list of allowed domains may use wildcards
* that match {@see is_domain_matching_pattern()}. Domains are compared in a case-insensitive manner
*
* @param string $domain Domain address
* @param array $alloweddomains An array of allowed domains.
@ -208,7 +208,7 @@ final class ip_utils {
// Use of wildcard for possible subdomains.
$escapeperiods = str_replace('.', '\.', $alloweddomain);
$replacewildcard = str_replace('*', '.*', $escapeperiods);
$ultimatepattern = '/' . $replacewildcard . '$/';
$ultimatepattern = '/' . $replacewildcard . '$/i';
if (preg_match($ultimatepattern, $domain)) {
return true;
}
@ -217,7 +217,7 @@ final class ip_utils {
continue;
}
// Strict domain setting.
if ($domain === $alloweddomain) {
if (strcasecmp($domain, $alloweddomain) === 0) {
return true;
}
}