git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] credential: treat "?" and "#" in URLs as end of host
Date: Wed, 15 Apr 2020 11:39:48 -0700	[thread overview]
Message-ID: <xmqqv9m061aj.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20200414214304.GA1887601@coredump.intra.peff.net> (Jeff King's message of "Tue, 14 Apr 2020 17:43:04 -0400")

Jeff King <peff@peff.net> writes:

> -	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 ;-)

> 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 ;-).


      parent reply	other threads:[~2020-04-15 19:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-14 21:43 [PATCH] credential: treat "?" and "#" in URLs as end of host Jeff King
2020-04-15  0:13 ` Taylor Blau
2020-04-15 18:39 ` Junio C Hamano [this message]

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=xmqqv9m061aj.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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).