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

Re: [PATCH] credential: treat "?" and "#" in URLs as end of host

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 15, 2020, 18:39 UTC
Message-ID
<xmqqv9m061aj.fsf@gitster.c.googlers.com>
In-Reply-To
<20200414214304.GA1887601@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 9 quoted lines
> -	slash = strchrnul(cp, '/');
> +
> +	/*
> +	 * A query or fragment marker before the slash ends the host portion.
> +	 * We'll just continue to call this "slash" for simplicity. Notably our
> +	 * "trim leading slashes" part won't skip over this part of the path,
> +	 * but that's what we'd want.
> +	 */
> +	slash = cp + strcspn(cp, "/?#");

Whatever happened when the original did not find any slash should happen in the new code when none of these three terminating bytes is found. The original made slash point at the end of the string, and the new code does the same.

So, by definition, the code is correct ;-)
Show 10 quoted lines
> diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh
> index 5b78ebbc3f..b6ec676989 100755
> --- a/t/t0300-credentials.sh
> +++ b/t/t0300-credentials.sh
> @@ -443,11 +443,45 @@ test_expect_success 'url parser ignores embedded newlines' '
>  	username=askpass-username
>  	password=askpass-password
>  	--
> -	warning: url contains a newline in its host component: https://one.example.com?%0ahost=two.example.com/
> +	warning: url contains a newline in its path component: https://one.example.com?%0ahost=two.example.com/
Nice demonstration ;-).
Previous: Taylor Blau
Message 3 of 3 in “credential: treat "?" and "#" in URLs as end of host”
  1. credential: treat "?" and "#" in URLs as end of hostJeff King, Apr 14, 2020
  2. Taylor BlauApr 15, 2020
  3. Junio C HamanoApr 15, 2020

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.