aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/pattern.go
diff options
context:
space:
mode:
authorJes Cok <xigua67damn@gmail.com>2024-02-24 11:52:38 +0000
committerJonathan Amsterdam <jba@google.com>2024-02-26 16:36:30 +0000
commit7b583fd1a1aeda98daa5a9d485b35786c031e941 (patch)
treef6d674bd6a29590a76e260b1bfa4e76a988aad88 /src/net/http/pattern.go
parent5225da7001e95d70771c054c40a4877911ab9f2b (diff)
downloadgo-7b583fd1a1aeda98daa5a9d485b35786c031e941.tar.xz
net/http: allow multiple spaces between method and path in mux patterns
Fixes #64910 Change-Id: I14fd1e35c95b14591e3ad7b889dc1ab19a008730 GitHub-Last-Rev: b8d436cdee93d103703e7e6d4bb28315c5035300 GitHub-Pull-Request: golang/go#65868 Reviewed-on: https://go-review.googlesource.com/c/go/+/565916 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'src/net/http/pattern.go')
-rw-r--r--src/net/http/pattern.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/net/http/pattern.go b/src/net/http/pattern.go
index f6af19b0f4..8fd120e777 100644
--- a/src/net/http/pattern.go
+++ b/src/net/http/pattern.go
@@ -76,7 +76,7 @@ type segment struct {
// a literal or a wildcard of the form "{name}", "{name...}", or "{$}".
//
// METHOD, HOST and PATH are all optional; that is, the string can be "/".
-// If METHOD is present, it must be followed by a single space.
+// If METHOD is present, it must be followed by at least one space or tab.
// Wildcard names must be valid Go identifiers.
// The "{$}" and "{name...}" wildcard must occur at the end of PATH.
// PATH may end with a '/'.
@@ -92,7 +92,10 @@ func parsePattern(s string) (_ *pattern, err error) {
}
}()
- method, rest, found := strings.Cut(s, " ")
+ method, rest, found := s, "", false
+ if i := strings.IndexAny(s, " \t"); i >= 0 {
+ method, rest, found = s[:i], strings.TrimLeft(s[i+1:], " \t"), true
+ }
if !found {
rest = method
method = ""