Subject: Re: [BUG] credential wildcard does not match hostnames containing an underscore

From: Junio C Hamano <[email-masked]>
Date: Tue, 12 Oct 2021 11:28:43 -0700

"Alex Waite" <[email-masked]> writes:

> Thanks for the response. :-)
>
>> Hmph, given that hostnames cannot have '_' (cf. RFC1123 2.1 "Host
>> Names and Numbers", for example), the third URL seems invalid.  Is
>> this even a bug?
>
> That is a fair question, and I do acknowledge that later on in my bug report (where I provide some additional information).
>
> The core issue, IMO, is that git is not consistent with itself. I
> can write a static rule that will match
> ("https://test_c.example.com") but cannot write a pattern that
> will do so.

I do not know if that is avoidable.

To be able to match a concrete URL that came from the running
session with a pattern taken from the configuration, we'd need to do
some parsing to figure out which part of the URL matches the
wildcard, and to be able to tell which substrings are "parts", there
needs some syntactic rule that says what constitutes a valid word.

I guess that we could make them consistent by treating a literal as
a pattern that does not happen to have any wildcard and reject the
"test_c" hostname the same way in both cases.  I do not offhand know
how desirable such a change would be.