From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Kyle J. McKay" <mackyle@gmail.com>, Alex Waite <alex@waite.eu>,
git@vger.kernel.org
Subject: Re: [BUG] credential wildcard does not match hostnames containing an underscore
Date: Tue, 12 Oct 2021 16:53:48 -0400 [thread overview]
Message-ID: <YWX13C7xsLcu+jZA@coredump.intra.peff.net> (raw)
In-Reply-To: <YWXzGeiUSMeq5Key@coredump.intra.peff.net>
On Tue, Oct 12, 2021 at 04:42:01PM -0400, Jeff King wrote:
> That may be so for hostnames in general, but URLs seem to allow it. RFC
> 3986 says:
>
> host = IP-literal / IPv4address / reg-name
> reg-name = *( unreserved / pct-encoded / sub-delims )
> unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
>
> So underscore is definitely allowed in the host portion. Our code
> complains during url_normalize(), in this code:
>
> if (allow_globs)
> spanned = strspn(url, URL_HOST_CHARS "*");
> else
> spanned = strspn(url, URL_HOST_CHARS);
>
> if (spanned < colon_ptr - url) {
> /* Host name has invalid characters */
> if (out_info) {
> out_info->url = NULL;
> out_info->err = _("invalid characters in host name");
> }
> strbuf_release(&norm);
> return NULL;
> }
>
> because earlier we define URL_HOST_CHARS without underscore:
>
> #define URL_HOST_CHARS URL_ALPHADIGIT ".-[:]" /* IPv6 literals need [:] */
>
> I'm not sure why, given that this otherwise seems to match according to
> the rfc. This code comes from 3402a8dc48 (config: add helper to
> normalize and match URLs, 2013-07-31), but there's no mention of
> underscore there. Possibly it came from earlier rules (rfc1738, for
> example, has a stricter grammar that allows only alphabit and dashes).
Sorry, I meant to cc the author of 3402a8dc48, which I've now done. It's
been a while, but maybe he remembers something (I couldn't find anything
digging in the archive, either).
-Peff
next prev parent reply other threads:[~2021-10-12 20:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-12 14:25 [BUG] credential wildcard does not match hostnames containing an underscore Alex Waite
2021-10-12 17:47 ` Junio C Hamano
2021-10-12 18:00 ` Alex Waite
2021-10-12 18:28 ` Junio C Hamano
2021-10-12 20:45 ` Jeff King
2021-10-12 20:42 ` Jeff King
2021-10-12 20:53 ` Jeff King [this message]
2021-10-12 21:12 ` [PATCH] urlmatch: add underscore to URL_HOST_CHARS Jeff King
2021-10-12 21:21 ` [BUG] credential wildcard does not match hostnames containing an underscore brian m. carlson
2021-10-12 21:32 ` Jeff King
2021-10-12 21:48 ` brian m. carlson
2021-10-12 21:55 ` Jeff King
2021-10-12 21:57 ` brian m. carlson
2021-10-12 22:25 ` Aaron Schrab
2021-10-13 16:21 ` Alex Waite
2021-10-14 11:43 ` Philip Oakley
2021-10-12 21:12 ` brian m. carlson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YWX13C7xsLcu+jZA@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=alex@waite.eu \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mackyle@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).