All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Ryan Hendrickson via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,
	 Ryan Hendrickson <ryan.hendrickson@alum.mit.edu>,
	Jeff King <peff@peff.net>
Subject: Re: [PATCH v3] http: do not ignore proxy path
Date: Wed, 31 Jul 2024 15:24:01 -0700	[thread overview]
Message-ID: <xmqqle1hyzcu.fsf@gitster.g> (raw)
In-Reply-To: <pull.1767.v3.git.1722441675945.gitgitgadget@gmail.com> (Ryan Hendrickson via GitGitGadget's message of "Wed, 31 Jul 2024 16:01:15 +0000")

"Ryan Hendrickson via GitGitGadget" <gitgitgadget@gmail.com> writes:

> @@ -5,8 +5,8 @@ http.proxy::
>  	proxy string with a user name but no password, in which case git will
>  	attempt to acquire one in the same way it does for other credentials. See
>  	linkgit:gitcredentials[7] for more information. The syntax thus is
> -	'[protocol://][user[:password]@]proxyhost[:port]'. This can be overridden
> -	on a per-remote basis; see remote.<name>.proxy
> +	'[protocol://][user[:password]@]proxyhost[:port][/path]'. This can be
> +	overridden on a per-remote basis; see remote.<name>.proxy

OK.

> diff --git a/http.c b/http.c
> index 623ed234891..a50ba095889 100644
> --- a/http.c
> +++ b/http.c
> @@ -1227,6 +1227,7 @@ static CURL *get_curl_handle(void)
>  		 */
>  		curl_easy_setopt(result, CURLOPT_PROXY, "");
>  	} else if (curl_http_proxy) {
> +		struct strbuf proxy = STRBUF_INIT;
>  		if (starts_with(curl_http_proxy, "socks5h"))
>  			curl_easy_setopt(result,
>  				CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME);

In a block with local variable decl, be more friendly to readers by
having a blank line between the end of declarations and the first
statement.

> +		strbuf_addstr(&proxy, proxy_auth.host);
> +		if (proxy_auth.path) {
> +			curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
> +			if (ver->version_num < 0x075400)
> +				die("libcurl 7.84 or later is required to support paths in proxy URLs");
> +
> +			if (!starts_with(proxy_auth.protocol, "socks"))
> +				die("Invalid proxy URL '%s': only SOCKS proxies support paths",
> +				    curl_http_proxy);
> +
> +			if (strcasecmp(proxy_auth.host, "localhost"))
> +				die("Invalid proxy URL '%s': host must be localhost if a path is present",
> +				    curl_http_proxy);

We insist that it must be "localhost", so let's not do strcasecmp()
but just do strcmp().

> diff --git a/t/t5564-http-proxy.sh b/t/t5564-http-proxy.sh
> index bb35b87071d..7fcffba67a2 100755
> --- a/t/t5564-http-proxy.sh
> +++ b/t/t5564-http-proxy.sh
> @@ -39,4 +39,50 @@ test_expect_success 'clone can prompt for proxy password' '
>  	expect_askpass pass proxuser
>  '
>  
> +start_socks() {
> +	mkfifo socks_output &&
> +	{
> +		"$PERL_PATH" "$TEST_DIRECTORY/socks4-proxy.pl" "$1" >socks_output &
> +		socks_pid=$!
> +	} &&
> +	read line <socks_output &&
> +	test "$line" = ready
> +}
> +
> +test_expect_success PERL 'try to start SOCKS proxy' '
> +	# The %30 tests that the correct amount of percent-encoding is applied
> +	# to the proxy string passed to curl.
> +	if start_socks %30.sock
> +	then
> +		test_set_prereq SOCKS_PROXY
> +	fi
> +'

Making it a regular test_expect_success would mean GIT_SKIP_TEST
mechansim can be used to skip it, which is probably not what you
want.  Can't this be a more common test_lazy_prereq, perhaps like

	test_lazy_prereq SOCKS_PROXY '
		# useful comment about 30% here ...
		test_have_prereq PERL &&
		start_socks %30.sock
	'

or something?

Thanks.

  reply	other threads:[~2024-07-31 22:24 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-26 15:52 [PATCH] http: do not ignore proxy path Ryan Hendrickson via GitGitGadget
2024-07-26 16:29 ` Junio C Hamano
2024-07-26 17:12   ` Ryan Hendrickson
2024-07-26 17:45     ` Junio C Hamano
2024-07-26 21:11 ` Jeff King
2024-07-26 22:43   ` Ryan Hendrickson
2024-07-29 19:31     ` Jeff King
2024-07-27  6:44 ` [PATCH v2] " Ryan Hendrickson via GitGitGadget
2024-07-29 20:09   ` Jeff King
2024-07-31 15:33     ` Ryan Hendrickson
2024-07-31 16:01   ` [PATCH v3] " Ryan Hendrickson via GitGitGadget
2024-07-31 22:24     ` Junio C Hamano [this message]
2024-08-01  3:44       ` Ryan Hendrickson
2024-08-01  5:21         ` Junio C Hamano
2024-08-01  5:45       ` Jeff King
2024-08-01 14:40         ` Junio C Hamano
2024-08-01  5:22     ` [PATCH v4] " Ryan Hendrickson via GitGitGadget
2024-08-01  6:04       ` Jeff King
2024-08-01 17:04         ` Junio C Hamano
2024-08-02  5:20       ` [PATCH v5] " Ryan Hendrickson via GitGitGadget
2024-08-02 15:52         ` Junio C Hamano
2024-08-02 16:43           ` Ryan Hendrickson
2024-08-02 17:10             ` Junio C Hamano
2024-08-02 18:03               ` Ryan Hendrickson
2024-08-02 19:28                 ` Junio C Hamano
2024-08-02 19:39                   ` Ryan Hendrickson
2024-08-02 21:13                     ` Junio C Hamano
2024-08-02 21:26                       ` Ryan Hendrickson
2024-08-02 21:43                         ` Junio C Hamano
2024-08-02 21:47                         ` Junio C Hamano
2024-08-02 22:14                           ` Ryan Hendrickson

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqle1hyzcu.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=peff@peff.net \
    --cc=ryan.hendrickson@alum.mit.edu \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.