Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport fix for t5559.{18,19,39} #4614

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,18 +620,43 @@ static int redact_sensitive_header(struct strbuf *header, size_t offset)
return ret;
}

static int match_curl_h2_trace(const char *line, const char **out)
{
const char *p;

/*
* curl prior to 8.1.0 gives us:
*
* h2h3 [<header-name>: <header-val>]
*
* Starting in 8.1.0, the first token became just "h2".
*/
if (skip_iprefix(line, "h2h3 [", out) ||
skip_iprefix(line, "h2 [", out))
return 1;

/*
* curl 8.3.0 uses:
* [HTTP/2] [<stream-id>] [<header-name>: <header-val>]
* where <stream-id> is numeric.
*/
if (skip_iprefix(line, "[HTTP/2] [", &p)) {
while (isdigit(*p))
p++;
if (skip_prefix(p, "] [", out))
return 1;
}

return 0;
}

/* Redact headers in info */
static void redact_sensitive_info_header(struct strbuf *header)
{
const char *sensitive_header;

/*
* curl's h2h3 prints headers in info, e.g.:
* h2h3 [<header-name>: <header-val>]
*/
if (trace_curl_redact &&
(skip_iprefix(header->buf, "h2h3 [", &sensitive_header) ||
skip_iprefix(header->buf, "h2 [", &sensitive_header))) {
match_curl_h2_trace(header->buf, &sensitive_header)) {
if (redact_sensitive_header(header, sensitive_header - header->buf)) {
/* redaction ate our closing bracket */
strbuf_addch(header, ']');
Expand Down
Loading