Subject: Re: [PATCH v4 1/3] send-mail: improve checks for valid_fqdn

From: Junio C Hamano <[email-masked]>
Date: Wed, 07 May 2025 15:42:00 -0700

Aditya Garg <[email-masked]> writes:

>  sub valid_fqdn {
>  	my $domain = shift;
> -	return defined $domain && !($^O eq 'darwin' && $domain =~ /\.local$/) && $domain =~ /\./;
> +	return defined $domain && !($^O eq 'darwin' && $domain =~ /\.local$/)
> +		&& $domain  =~ /^(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\.(?!-)[A-Za-z0-9-]{1,63}(?<!-))*$/;

Yuck, can we do something about this overly long mess?  

If use a temporary $subdomain = '(?!-)[A-Za-z0-9-]{1,63}(?<!-)',
would it make it easier to spot the repetition in the structure,
i.e. /^$subdomain(?:\.$subdomain)*$/ and make it less error prone
when somebody has to touch lines around here, or something?

But other than that, looking good.

Even though this allows "foo.local", on "darwin" it is still not
allowed, which sounds like a regression-free change.

Thanks.