1
0
mirror of https://github.com/mailcow/mailcow-dockerized.git synced 2025-12-15 19:06:03 +00:00

[Web] Allow wildcard subdomains for MTA-STS

This commit is contained in:
FreddleSpl0it
2025-09-22 13:55:18 +02:00
parent 78168ee80a
commit a36485f0f1
2 changed files with 13 additions and 3 deletions

View File

@@ -1107,11 +1107,21 @@ function user_get_alias_details($username) {
}
return $data;
}
function is_valid_domain_name($domain_name) {
function is_valid_domain_name($domain_name, $options = array()) {
if (empty($domain_name)) {
return false;
}
// Convert domain name to ASCII for validation
$domain_name = idn_to_ascii($domain_name, 0, INTL_IDNA_VARIANT_UTS46);
// Remove '*.' if wildcard subdomains are allowed
if (isset($options['allow_wildcard']) &&
$options['allow_wildcard'] == true &&
strpos($domain_name, '*.') === 0) {
$domain_name = substr($domain_name, 2);
}
return (preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i", $domain_name)
&& preg_match("/^.{1,253}$/", $domain_name)
&& preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain_name));