From cf058730293ac95ce0df40db8068219fe21cbb8a Mon Sep 17 00:00:00 2001 From: Jonathan Amsterdam Date: Sat, 27 Apr 2024 08:04:28 -0400 Subject: net/http: represent multi wildcards properly The routing tree used for matching ServeMux patterns used the key "*" to hold a child node for a multi-segment wildcard. The problem is that "*" is a valid path segment, which confused the matching algorithm: it would fetch the multi wildcard child when looking for the literal child for "*". Eschew clever encodings. Use a separate field in the node to represent the multi wildcard child. Fixes #67067. Change-Id: I300ca08b8628f5367626cf41979f6c238ed8c831 Reviewed-on: https://go-review.googlesource.com/c/go/+/582115 LUCI-TryBot-Result: Go LUCI Reviewed-by: Damien Neil --- src/net/http/request_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/net/http/request_test.go') diff --git a/src/net/http/request_test.go b/src/net/http/request_test.go index 8c8116123c..a7deba46e3 100644 --- a/src/net/http/request_test.go +++ b/src/net/http/request_test.go @@ -1559,6 +1559,14 @@ func TestPathValue(t *testing.T) { "other": "there/is//more", }, }, + { + "/names/{name}/{other...}", + "/names/n/*", + map[string]string{ + "name": "n", + "other": "*", + }, + }, } { mux := NewServeMux() mux.HandleFunc(test.pattern, func(w ResponseWriter, r *Request) { -- cgit v1.3-6-g1900