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

From: Junio C Hamano <[email-masked]>
Date: Tue, 06 May 2025 15:07:48 -0700

Aditya Garg <[email-masked]> writes:

>>  * ... but I don't know if your use of negative lookaround
>>    assersions is correct.  Shouldn't the "a label cannot begin or
>>    end with dash" be applied not just to the first label but
>>    consistently to all of the dot-separated labels?
>
> I think you are talking about this case:
>
> someone.-example.com
>
> No, its not valid.a

I was not talking about any "case"; I was talking more about your
regexp to catch invalid addresses.  From RFC 5321,

    helo       = "HELO" SP Domain CRLF
    Domain     = sub-domain *("." sub-domain)
    sub-domain = Let-dig [Ldh-str]
    Let-dig    = ALPHA / DIGIT
    Ldh-str    = *( ALPHA / DIGIT / "-" ) Let-dig

so the syntax for first "sub-domain" applies equally to the other
"sub-domain".  If "-example" cannot be the third-level subdomain,
then it equally cannot be the second-level, either, but IIRC, the
patch had regexp that treated the first level differently from the
rest.