git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] http: update curl http/2 info matching for curl 8.3.0

From
Jeff King <peff@peff.net>
Date
Sep 15, 2023, 11:34 UTC
Message-ID
<20230915113443.GB3531587@coredump.intra.peff.net>
In-Reply-To
<20230915113237.GA3531328@coredump.intra.peff.net>

To redact header lines in http/2 curl traces, we have to parse past some prefix bytes that curl sticks in the info lines it passes to us. That changed once already, and we adapted in db30130165 (http: handle both "h2" and "h2h3" in curl info lines, 2023-06-17).

Now it has changed again, in curl's fbacb14c4 (http2: cleanup trace messages, 2023-08-04), which was released in curl 8.3.0. Running a build of git linked against that version will fail to redact the trace (and as before, t5559 notices and complains).

The format here is a little more complicated than the other ones, as it now includes a "stream id". This is not constant but is always numeric, so we can easily parse past it.

We'll continue to match the old versions, of course, since we want to work with many different versions of curl. We can't even select one format at compile time, because the behavior depends on the runtime version of curl we use, not the version we build against.

Signed-off-by: Jeff King <peff@peff.net>
---
 http.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff --git a/http.c b/http.c
index c93e0a7ea6..8f71bf00d8 100644
--- a/http.c
+++ b/http.c
@@ -740,6 +740,8 @@ static int redact_sensitive_header(struct strbuf *header, size_t offset)
 
 static int match_curl_h2_trace(const char *line, const char **out)
 {
+	const char *p;
+
 	/*
 	 * curl prior to 8.1.0 gives us:
 	 *
@@ -751,6 +753,18 @@ static int match_curl_h2_trace(const char *line, const char **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;
 }
 
-- 
2.42.0.661.g2507eb519e
Previous: Taylor BlauNext: Junio C Hamano
Message 4 of 10 in “updating curl http/2 header matching (again)”
  1. 0/2 updating curl http/2 header matching (again)Jeff King, Sep 15, 2023
  2. 1/2 http: factor out matching of curl http/2 trace linesJeff King, Sep 15, 2023
  3. Taylor BlauSep 15, 2023
  4. 2/2 http: update curl http/2 info matching for curl 8.3.0Jeff King, Sep 15, 2023
  5. Junio C HamanoSep 15, 2023
  6. Jeff KingSep 16, 2023
  7. Taylor BlauSep 15, 2023
  8. Jeff KingSep 16, 2023
  9. Taylor BlauSep 19, 2023
  10. Taylor BlauSep 15, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.