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

Re: [PATCH] fetch: Strip usernames from url's before storing them

From
Andreas Ericsson <ae@op5.se>
Date
Apr 15, 2009, 14:14 UTC
Message-ID
<49E5EBD2.1070704@op5.se>
In-Reply-To
<49E5DE98.1080600@viscovery.net>
Johannes Sixt wrote:
Show 26 quoted lines
> Andreas Ericsson schrieb:
>> +/*
>> + * strip username information from the url
>> + * This will allocate a new string, or return its argument
>> + * if no stripping is necessary.
>> + *
>> + * The url's we want to catch are the following:
>> + *   ssh://[user@]host.xz[:port]/path/to/repo.git/
>> + *   [user@]host.xz:/path/to/repo.git/
>> + *   http[s]://[user[:password]@]host.xz/path/to/repo.git
>> + *
>> + * Although git doesn't currently support giving the password
>> + * to http url's on the command-line, it's easier to catch
>> + * that case too than it is to cater for it specially.
>> + */
>> +static char *anonymize_url(const char *url)
>> +{
>> +	char *anon_url;
>> +	const char *at_sign = strchr(url, '@');
>> +	size_t prefix_len = 0;
>> +
>> +	if (!at_sign)
> 
> 	if (!at_sign || has_dos_drive_prefix(url))
> 
> or even better move this function to transport.c and use is_local().

Good idea, even though it really shouldn't matter in practice due to the last if() below. Then again, there's no telling what some silly IDE might take into its head to name paths ;-)

I also see now I botched the job and sent the un-amended patch. v2 incoming.

Show 12 quoted lines
> 
>> +		return strdup(url);
>> +
>> +	if (!prefixcmp(url, "ssh://"))
>> +		prefix_len = strlen("ssh://");
>> +	else if (!prefixcmp(url, "http://"))
>> +		prefix_len = strlen("http://");
>> +	else if (!prefixcmp(url, "https://"))
>> +		prefix_len = strlen("https://");
>> +	else if (!strchr(at_sign + 1, ':'))
>> +		return strdup(url);
>> +
-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
Previous: Johannes SixtNext: Andreas Ericsson
Message 7 of 13 in “fetch: Strip usernames from url's before storing them”
  1. fetch: Strip usernames from url's before storing themAndreas Ericsson, Apr 15, 2009
  2. Michael J GruberApr 15, 2009
  3. Andreas EricssonApr 15, 2009
  4. Junio C HamanoApr 15, 2009
  5. Andreas EricssonApr 15, 2009
  6. Johannes SixtApr 15, 2009
  7. Andreas EricssonApr 15, 2009
  8. fetch: Strip usernames from url's before storing themAndreas Ericsson, Apr 15, 2009
  9. Junio C HamanoApr 15, 2009
  10. Andreas EricssonApr 15, 2009
  11. fetch: Strip usernames from url's before storing themAndreas Ericsson, Apr 17, 2009
  12. Andreas EricssonApr 20, 2009
  13. Junio C HamanoApr 20, 2009

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.