Skip to content

Commit 49aad3c

Browse files
authored
Backport fix for t5559.{18,19,39} (#4614)
HTTP Header redaction code has been adjusted for a newer version of cURL library that shows its traces differently from earlier versions. This is purely a fix for Git's test suite, no Git behavior is actually changed by this PR, read: it has no user-visible changes. This PR is a close relative of microsoft#609.
2 parents 49f75ff + 0763c3a commit 49aad3c

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

http.c

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -763,18 +763,43 @@ static int redact_sensitive_header(struct strbuf *header, size_t offset)
763763
return ret;
764764
}
765765

766+
static int match_curl_h2_trace(const char *line, const char **out)
767+
{
768+
const char *p;
769+
770+
/*
771+
* curl prior to 8.1.0 gives us:
772+
*
773+
* h2h3 [<header-name>: <header-val>]
774+
*
775+
* Starting in 8.1.0, the first token became just "h2".
776+
*/
777+
if (skip_iprefix(line, "h2h3 [", out) ||
778+
skip_iprefix(line, "h2 [", out))
779+
return 1;
780+
781+
/*
782+
* curl 8.3.0 uses:
783+
* [HTTP/2] [<stream-id>] [<header-name>: <header-val>]
784+
* where <stream-id> is numeric.
785+
*/
786+
if (skip_iprefix(line, "[HTTP/2] [", &p)) {
787+
while (isdigit(*p))
788+
p++;
789+
if (skip_prefix(p, "] [", out))
790+
return 1;
791+
}
792+
793+
return 0;
794+
}
795+
766796
/* Redact headers in info */
767797
static void redact_sensitive_info_header(struct strbuf *header)
768798
{
769799
const char *sensitive_header;
770800

771-
/*
772-
* curl's h2h3 prints headers in info, e.g.:
773-
* h2h3 [<header-name>: <header-val>]
774-
*/
775801
if (trace_curl_redact &&
776-
(skip_iprefix(header->buf, "h2h3 [", &sensitive_header) ||
777-
skip_iprefix(header->buf, "h2 [", &sensitive_header))) {
802+
match_curl_h2_trace(header->buf, &sensitive_header)) {
778803
if (redact_sensitive_header(header, sensitive_header - header->buf)) {
779804
/* redaction ate our closing bracket */
780805
strbuf_addch(header, ']');

0 commit comments

Comments
 (0)