Commit 5a13d4ca by lmcglash Committed by Edward Thomson

Validate proxy URL on Windows.

parent 402f63a4
......@@ -334,16 +334,13 @@ static int lookup_proxy(
return 0;
}
if (!proxy)
goto done;
if ((error = git_net_url_parse(&transport->proxy.url, proxy) < 0))
if (!proxy ||
(error = git_net_url_parse(&transport->proxy.url, proxy)) < 0)
goto done;
if (!git_net_url_valid(&transport->proxy.url)) {
git_error_set(GIT_ERROR_HTTP, "invalid proxy url: %s", proxy);
error = GIT_EINVALIDSPEC;
git_error_set(GIT_ERROR_HTTP, "invalid URL: '%s'", proxy);
error = -1;
goto done;
}
......
......@@ -446,7 +446,7 @@ static int winhttp_stream_connect(winhttp_stream *s)
if ((error = git_net_url_parse(&t->proxy.url, proxy_url)) < 0)
goto on_error;
if (strcmp(t->proxy.url.scheme, "http") != 0 && strcmp(t->proxy.url.scheme, "https") != 0) {
if (!git_net_url_valid(&t->proxy.url)) {
git_error_set(GIT_ERROR_HTTP, "invalid URL: '%s'", proxy_url);
error = -1;
goto on_error;
......
......@@ -975,10 +975,10 @@ void test_online_clone__proxy_invalid_url(void)
g_options.fetch_opts.proxy_opts.certificate_check = proxy_cert_cb;
g_options.fetch_opts.proxy_opts.url = "noschemeorport";
cl_git_fail_with(GIT_EINVALIDSPEC, git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
cl_git_fail(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
g_options.fetch_opts.proxy_opts.url = "noscheme:8080";
cl_git_fail_with(GIT_EINVALIDSPEC, git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
cl_git_fail(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
}
void test_online_clone__proxy_credentials_request(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment