Modern DNS records can contain underscores for a number of reasons. In
particular, DKIM records involve a "_domainkey" part,
https://tools.ietf.org/html/rfc6376
that is rejected by the current "fqdn" and "p" validation routines.
Moreover, any SRV records will have a service name prefixed with an
underscore:
https://tools.ietf.org/html/rfc2782
To recognize these tokens as valid, this commit expands the "fqdn" and
"p" regular expressions to allow underscores as the first character in
each component of an FQDN.
# check all parts
for my $hostpart (split /\./, $s)
{
- return 1005 unless $hostpart =~ /^[-a-z0-9]+$/i;
+ return 1005 unless $hostpart =~ /^_?[-a-z0-9]+$/i;
return 1006 if $hostpart =~ /^-/;
return 1007 if $hostpart =~ /-$/;
}
# check all parts
for (split /\./, $s)
{
- return 1005 unless /^[-[a-z0-9]+$/i;
+ return 1005 unless /^_?[-[a-z0-9]+$/i;
return 1006 if /^-/;
return 1007 if /-$/;
}