git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] http: handle curl stripping creds from effective url

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 28, 2026, 15:01 UTC
Message-ID
<xmqqo6dho1xj.fsf@gitster.g>
In-Reply-To
<20260928040149.GA498186@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 9 quoted lines
> I've used curl's curl_url() interface to do the stripping here, mostly
> because its behavior should match the stripping it does internally. And
> also, though we have code to parse a URL, we don't have any to
> reconstruct it, making a single string comparison hard.
>
> One alternative would be to parse with url_parse() or similar, and
> compare the individual fields (skipping username/password). I think that
> would probably also work in practice, but it seemed to me that the
> simplest change would be sticking with string comparisons.
Very nice.
> The curl_url() interface appeared in 7.62.0. We document that 7.61.0 is
> still supported, so I've made it conditional here. Only new versions
> strip the result from CURLINFO_EFFECTIVE_URL, so it's OK for very old
> versions to skip the extra comparison.
;-)
> We could probably declare 7.62.0 the oldest supported version of curl,
> but it would really only save a few lines of #ifdef here. I'd prefer to
> consider that question separately.
That is very sensible.
Show 24 quoted lines
> +#ifndef GIT_CURL_HAVE_CURL_URL
> +#define strip_url_credential(in) NULL
> +#else
> +static char *strip_url_credential(const char *in)
> +{
> +	char *ret = NULL;
> +	CURLU *url;
> +
> +	url = curl_url();
> +	if (!url)
> +		goto out;
> +
> +	if (curl_url_set(url, CURLUPART_URL, in, 0))
> +		goto out;
> +
> +	curl_url_set(url, CURLUPART_USER, NULL, 0);
> +	curl_url_set(url, CURLUPART_PASSWORD, NULL, 0);
> +	curl_url_get(url, CURLUPART_URL, &ret, 0);
> +
> +out:
> +	curl_url_cleanup(url);
> +	return ret;
> +}
> +#endif
Previous: Patrick Steinhardt
Message 5 of 5 in “http: handle curl stripping creds from effective url”
  1. http: handle curl stripping creds from effective urlJeff King, Sep 28, 2026
  2. Patrick SteinhardtSep 28, 2026
  3. Jeff KingSep 28, 2026
  4. Patrick SteinhardtSep 29, 2026
  5. Junio C HamanoSep 28, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.