strbuf: give URL-encoding API a char predicate fn

Allow callers to specify exactly what characters need to be URL-encoded
and which do not. This new API will be taken advantage of in a patch
later in this set.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Matthew DeVore <matvore@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Matthew DeVore
2019-06-27 15:54:11 -07:00
committed by Junio C Hamano
parent cf9ceb5a12
commit c2694952e3
4 changed files with 23 additions and 14 deletions

6
http.c
View File

@ -513,9 +513,11 @@ static void set_proxyauth_name_password(CURL *result)
#else
struct strbuf s = STRBUF_INIT;
strbuf_addstr_urlencode(&s, proxy_auth.username, 1);
strbuf_addstr_urlencode(&s, proxy_auth.username,
is_rfc3986_unreserved);
strbuf_addch(&s, ':');
strbuf_addstr_urlencode(&s, proxy_auth.password, 1);
strbuf_addstr_urlencode(&s, proxy_auth.password,
is_rfc3986_unreserved);
curl_proxyuserpwd = strbuf_detach(&s, NULL);
curl_easy_setopt(result, CURLOPT_PROXYUSERPWD, curl_proxyuserpwd);
#endif