From c61d004ca2151ab79f045b7c0332c52818254767 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Jun 2025 14:25:05 +0000 Subject: [PATCH] build(deps): bump github.com/go-chi/chi/v5 from 5.2.1 to 5.2.2 Bumps [github.com/go-chi/chi/v5](https://github.com/go-chi/chi) from 5.2.1 to 5.2.2. - [Release notes](https://github.com/go-chi/chi/releases) - [Changelog](https://github.com/go-chi/chi/blob/master/CHANGELOG.md) - [Commits](https://github.com/go-chi/chi/compare/v5.2.1...v5.2.2) --- updated-dependencies: - dependency-name: github.com/go-chi/chi/v5 dependency-version: 5.2.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- vendor/github.com/go-chi/chi/v5/README.md | 6 +++-- vendor/github.com/go-chi/chi/v5/chi.go | 3 +-- .../go-chi/chi/v5/middleware/compress.go | 24 +++++++------------ .../chi/v5/middleware/content_charset.go | 9 ++++--- .../go-chi/chi/v5/middleware/content_type.go | 4 ++-- .../go-chi/chi/v5/middleware/profiler.go | 3 +++ .../go-chi/chi/v5/middleware/realip.go | 6 +---- .../go-chi/chi/v5/middleware/route_headers.go | 8 +------ .../go-chi/chi/v5/middleware/strip.go | 10 ++++---- .../go-chi/chi/v5/middleware/throttle.go | 2 +- .../go-chi/chi/v5/middleware/wrap_writer.go | 7 +++--- vendor/github.com/go-chi/chi/v5/mux.go | 10 ++++---- vendor/github.com/go-chi/chi/v5/path_value.go | 5 ++-- .../go-chi/chi/v5/path_value_fallback.go | 4 ++-- vendor/github.com/go-chi/chi/v5/tree.go | 6 ++--- vendor/modules.txt | 2 +- 18 files changed, 49 insertions(+), 66 deletions(-) diff --git a/go.mod b/go.mod index 87affc0d5f..28ba5375c3 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/egirna/icap-client v0.1.1 github.com/gabriel-vasile/mimetype v1.4.9 github.com/ggwhite/go-masker v1.1.0 - github.com/go-chi/chi/v5 v5.2.1 + github.com/go-chi/chi/v5 v5.2.2 github.com/go-chi/render v1.0.3 github.com/go-ldap/ldap/v3 v3.4.11 github.com/go-ldap/ldif v0.0.0-20200320164324-fd88d9b715b3 diff --git a/go.sum b/go.sum index 81f249ae13..47f63dd6c2 100644 --- a/go.sum +++ b/go.sum @@ -340,8 +340,8 @@ github.com/go-asn1-ber/asn1-ber v1.4.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkPro github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667 h1:BP4M0CvQ4S3TGls2FvczZtj5Re/2ZzkV9VwqPHH/3Bo= github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= -github.com/go-chi/chi/v5 v5.2.1 h1:KOIHODQj58PmL80G2Eak4WdvUzjSJSm0vG72crDCqb8= -github.com/go-chi/chi/v5 v5.2.1/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops= +github.com/go-chi/chi/v5 v5.2.2 h1:CMwsvRVTbXVytCk1Wd72Zy1LAsAh9GxMmSNWLHCG618= +github.com/go-chi/chi/v5 v5.2.2/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops= github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4= github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0= github.com/go-cmd/cmd v1.0.5/go.mod h1:y8q8qlK5wQibcw63djSl/ntiHUHXHGdCkPk0j4QeW4s= diff --git a/vendor/github.com/go-chi/chi/v5/README.md b/vendor/github.com/go-chi/chi/v5/README.md index 7f662ab45f..c58a0e20ce 100644 --- a/vendor/github.com/go-chi/chi/v5/README.md +++ b/vendor/github.com/go-chi/chi/v5/README.md @@ -20,7 +20,9 @@ and [docgen](https://github.com/go-chi/docgen). We hope you enjoy it too! ## Install -`go get -u github.com/go-chi/chi/v5` +```sh +go get -u github.com/go-chi/chi/v5 +``` ## Features @@ -194,7 +196,7 @@ type Router interface { // path, with a fresh middleware stack for the inline-Router. Group(fn func(r Router)) Router - // Route mounts a sub-Router along a `pattern`` string. + // Route mounts a sub-Router along a `pattern` string. Route(pattern string, fn func(r Router)) Router // Mount attaches another http.Handler along ./pattern/* diff --git a/vendor/github.com/go-chi/chi/v5/chi.go b/vendor/github.com/go-chi/chi/v5/chi.go index fc32c4efe9..2b6ebd337c 100644 --- a/vendor/github.com/go-chi/chi/v5/chi.go +++ b/vendor/github.com/go-chi/chi/v5/chi.go @@ -37,8 +37,7 @@ // // A placeholder with a name followed by a colon allows a regular // expression match, for example {number:\\d+}. The regular expression -// syntax is Go's normal regexp RE2 syntax, except that regular expressions -// including { or } are not supported, and / will never be +// syntax is Go's normal regexp RE2 syntax, except that / will never be // matched. An anonymous regexp pattern is allowed, using an empty string // before the colon in the placeholder, such as {:\\d+} // diff --git a/vendor/github.com/go-chi/chi/v5/middleware/compress.go b/vendor/github.com/go-chi/chi/v5/middleware/compress.go index 28240c4b3a..9c64bd48dc 100644 --- a/vendor/github.com/go-chi/chi/v5/middleware/compress.go +++ b/vendor/github.com/go-chi/chi/v5/middleware/compress.go @@ -7,7 +7,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net" "net/http" "strings" @@ -160,16 +159,14 @@ func (c *Compressor) SetEncoder(encoding string, fn EncoderFunc) { delete(c.encoders, encoding) // If the encoder supports Resetting (IoReseterWriter), then it can be pooled. - encoder := fn(ioutil.Discard, c.level) - if encoder != nil { - if _, ok := encoder.(ioResetterWriter); ok { - pool := &sync.Pool{ - New: func() interface{} { - return fn(ioutil.Discard, c.level) - }, - } - c.pooledEncoders[encoding] = pool + encoder := fn(io.Discard, c.level) + if _, ok := encoder.(ioResetterWriter); ok { + pool := &sync.Pool{ + New: func() interface{} { + return fn(io.Discard, c.level) + }, } + c.pooledEncoders[encoding] = pool } // If the encoder is not in the pooledEncoders, add it to the normal encoders. if _, ok := c.pooledEncoders[encoding]; !ok { @@ -277,16 +274,13 @@ type compressResponseWriter struct { func (cw *compressResponseWriter) isCompressible() bool { // Parse the first part of the Content-Type response header. contentType := cw.Header().Get("Content-Type") - if idx := strings.Index(contentType, ";"); idx >= 0 { - contentType = contentType[0:idx] - } + contentType, _, _ = strings.Cut(contentType, ";") // Is the content type compressible? if _, ok := cw.contentTypes[contentType]; ok { return true } - if idx := strings.Index(contentType, "/"); idx > 0 { - contentType = contentType[0:idx] + if contentType, _, hadSlash := strings.Cut(contentType, "/"); hadSlash { _, ok := cw.contentWildcards[contentType] return ok } diff --git a/vendor/github.com/go-chi/chi/v5/middleware/content_charset.go b/vendor/github.com/go-chi/chi/v5/middleware/content_charset.go index 07b5ce6f66..07bff9f2e3 100644 --- a/vendor/github.com/go-chi/chi/v5/middleware/content_charset.go +++ b/vendor/github.com/go-chi/chi/v5/middleware/content_charset.go @@ -40,11 +40,10 @@ func contentEncoding(ce string, charsets ...string) bool { // Split a string in two parts, cleaning any whitespace. func split(str, sep string) (string, string) { - var a, b string - var parts = strings.SplitN(str, sep, 2) - a = strings.TrimSpace(parts[0]) - if len(parts) == 2 { - b = strings.TrimSpace(parts[1]) + a, b, found := strings.Cut(str, sep) + a = strings.TrimSpace(a) + if found { + b = strings.TrimSpace(b) } return a, b diff --git a/vendor/github.com/go-chi/chi/v5/middleware/content_type.go b/vendor/github.com/go-chi/chi/v5/middleware/content_type.go index e61ff26403..cdfc21eec5 100644 --- a/vendor/github.com/go-chi/chi/v5/middleware/content_type.go +++ b/vendor/github.com/go-chi/chi/v5/middleware/content_type.go @@ -31,7 +31,8 @@ func AllowContentType(contentTypes ...string) func(http.Handler) http.Handler { return } - s := strings.ToLower(strings.TrimSpace(strings.Split(r.Header.Get("Content-Type"), ";")[0])) + s, _, _ := strings.Cut(r.Header.Get("Content-Type"), ";") + s = strings.ToLower(strings.TrimSpace(s)) if _, ok := allowedContentTypes[s]; ok { next.ServeHTTP(w, r) @@ -42,4 +43,3 @@ func AllowContentType(contentTypes ...string) func(http.Handler) http.Handler { }) } } - diff --git a/vendor/github.com/go-chi/chi/v5/middleware/profiler.go b/vendor/github.com/go-chi/chi/v5/middleware/profiler.go index ebd81ee4f6..0ad6a996bc 100644 --- a/vendor/github.com/go-chi/chi/v5/middleware/profiler.go +++ b/vendor/github.com/go-chi/chi/v5/middleware/profiler.go @@ -1,3 +1,6 @@ +//go:build !tinygo +// +build !tinygo + package middleware import ( diff --git a/vendor/github.com/go-chi/chi/v5/middleware/realip.go b/vendor/github.com/go-chi/chi/v5/middleware/realip.go index 55c95a8992..afcb79e201 100644 --- a/vendor/github.com/go-chi/chi/v5/middleware/realip.go +++ b/vendor/github.com/go-chi/chi/v5/middleware/realip.go @@ -47,11 +47,7 @@ func realIP(r *http.Request) string { } else if xrip := r.Header.Get(xRealIP); xrip != "" { ip = xrip } else if xff := r.Header.Get(xForwardedFor); xff != "" { - i := strings.Index(xff, ",") - if i == -1 { - i = len(xff) - } - ip = xff[:i] + ip, _, _ = strings.Cut(xff, ",") } if ip == "" || net.ParseIP(ip) == nil { return "" diff --git a/vendor/github.com/go-chi/chi/v5/middleware/route_headers.go b/vendor/github.com/go-chi/chi/v5/middleware/route_headers.go index 997bed569a..88743769a7 100644 --- a/vendor/github.com/go-chi/chi/v5/middleware/route_headers.go +++ b/vendor/github.com/go-chi/chi/v5/middleware/route_headers.go @@ -133,13 +133,7 @@ type Pattern struct { func NewPattern(value string) Pattern { p := Pattern{} - if i := strings.IndexByte(value, '*'); i >= 0 { - p.wildcard = true - p.prefix = value[0:i] - p.suffix = value[i+1:] - } else { - p.prefix = value - } + p.prefix, p.suffix, p.wildcard = strings.Cut(value, "*") return p } diff --git a/vendor/github.com/go-chi/chi/v5/middleware/strip.go b/vendor/github.com/go-chi/chi/v5/middleware/strip.go index 1368fa7ab7..17aa9bf32a 100644 --- a/vendor/github.com/go-chi/chi/v5/middleware/strip.go +++ b/vendor/github.com/go-chi/chi/v5/middleware/strip.go @@ -3,6 +3,7 @@ package middleware import ( "fmt" "net/http" + "strings" "github.com/go-chi/chi/v5" ) @@ -47,13 +48,12 @@ func RedirectSlashes(next http.Handler) http.Handler { path = r.URL.Path } if len(path) > 1 && path[len(path)-1] == '/' { + // Trim all leading and trailing slashes (e.g., "//evil.com", "/some/path//") + path = "/" + strings.Trim(path, "/") if r.URL.RawQuery != "" { - path = fmt.Sprintf("%s?%s", path[:len(path)-1], r.URL.RawQuery) - } else { - path = path[:len(path)-1] + path = fmt.Sprintf("%s?%s", path, r.URL.RawQuery) } - redirectURL := fmt.Sprintf("//%s%s", r.Host, path) - http.Redirect(w, r, redirectURL, 301) + http.Redirect(w, r, path, 301) return } next.ServeHTTP(w, r) diff --git a/vendor/github.com/go-chi/chi/v5/middleware/throttle.go b/vendor/github.com/go-chi/chi/v5/middleware/throttle.go index 9a870d88b6..b1f926de95 100644 --- a/vendor/github.com/go-chi/chi/v5/middleware/throttle.go +++ b/vendor/github.com/go-chi/chi/v5/middleware/throttle.go @@ -126,9 +126,9 @@ type token struct{} type throttler struct { tokens chan token backlogTokens chan token + retryAfterFn func(ctxDone bool) time.Duration backlogTimeout time.Duration statusCode int - retryAfterFn func(ctxDone bool) time.Duration } // setRetryAfterHeaderIfNeeded sets Retry-After HTTP header if corresponding retryAfterFn option of throttler is initialized. diff --git a/vendor/github.com/go-chi/chi/v5/middleware/wrap_writer.go b/vendor/github.com/go-chi/chi/v5/middleware/wrap_writer.go index 12d4faf017..367e0fcd92 100644 --- a/vendor/github.com/go-chi/chi/v5/middleware/wrap_writer.go +++ b/vendor/github.com/go-chi/chi/v5/middleware/wrap_writer.go @@ -6,7 +6,6 @@ package middleware import ( "bufio" "io" - "io/ioutil" "net" "net/http" ) @@ -73,10 +72,10 @@ type WrapResponseWriter interface { // http.ResponseWriter interface. type basicWriter struct { http.ResponseWriter - wroteHeader bool + tee io.Writer code int bytes int - tee io.Writer + wroteHeader bool discard bool } @@ -108,7 +107,7 @@ func (b *basicWriter) Write(buf []byte) (n int, err error) { } else if b.tee != nil { n, err = b.tee.Write(buf) } else { - n, err = ioutil.Discard.Write(buf) + n, err = io.Discard.Write(buf) } b.bytes += n return n, err diff --git a/vendor/github.com/go-chi/chi/v5/mux.go b/vendor/github.com/go-chi/chi/v5/mux.go index 91daf691e9..f1266971b4 100644 --- a/vendor/github.com/go-chi/chi/v5/mux.go +++ b/vendor/github.com/go-chi/chi/v5/mux.go @@ -107,9 +107,8 @@ func (mx *Mux) Use(middlewares ...func(http.Handler) http.Handler) { // Handle adds the route `pattern` that matches any http method to // execute the `handler` http.Handler. func (mx *Mux) Handle(pattern string, handler http.Handler) { - parts := strings.SplitN(pattern, " ", 2) - if len(parts) == 2 { - mx.Method(parts[0], parts[1], handler) + if method, rest, found := strings.Cut(pattern, " "); found { + mx.Method(method, rest, handler) return } @@ -119,9 +118,8 @@ func (mx *Mux) Handle(pattern string, handler http.Handler) { // HandleFunc adds the route `pattern` that matches any http method to // execute the `handlerFn` http.HandlerFunc. func (mx *Mux) HandleFunc(pattern string, handlerFn http.HandlerFunc) { - parts := strings.SplitN(pattern, " ", 2) - if len(parts) == 2 { - mx.Method(parts[0], parts[1], handlerFn) + if method, rest, found := strings.Cut(pattern, " "); found { + mx.Method(method, rest, handlerFn) return } diff --git a/vendor/github.com/go-chi/chi/v5/path_value.go b/vendor/github.com/go-chi/chi/v5/path_value.go index 7e78171e5c..77c840f019 100644 --- a/vendor/github.com/go-chi/chi/v5/path_value.go +++ b/vendor/github.com/go-chi/chi/v5/path_value.go @@ -1,5 +1,6 @@ -//go:build go1.22 -// +build go1.22 +//go:build go1.22 && !tinygo +// +build go1.22,!tinygo + package chi diff --git a/vendor/github.com/go-chi/chi/v5/path_value_fallback.go b/vendor/github.com/go-chi/chi/v5/path_value_fallback.go index f551781a43..749a8520a7 100644 --- a/vendor/github.com/go-chi/chi/v5/path_value_fallback.go +++ b/vendor/github.com/go-chi/chi/v5/path_value_fallback.go @@ -1,5 +1,5 @@ -//go:build !go1.22 -// +build !go1.22 +//go:build !go1.22 || tinygo +// +build !go1.22 tinygo package chi diff --git a/vendor/github.com/go-chi/chi/v5/tree.go b/vendor/github.com/go-chi/chi/v5/tree.go index c7d3bc5704..85fcfdbb8d 100644 --- a/vendor/github.com/go-chi/chi/v5/tree.go +++ b/vendor/github.com/go-chi/chi/v5/tree.go @@ -730,11 +730,9 @@ func patNextSegment(pattern string) (nodeTyp, string, string, byte, int, int) { tail = pattern[pe] } - var rexpat string - if idx := strings.Index(key, ":"); idx >= 0 { + key, rexpat, isRegexp := strings.Cut(key, ":") + if isRegexp { nt = ntRegexp - rexpat = key[idx+1:] - key = key[:idx] } if len(rexpat) > 0 { diff --git a/vendor/modules.txt b/vendor/modules.txt index 3eca48b25e..2387280ae1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -442,7 +442,7 @@ github.com/go-acme/lego/v4/challenge # github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667 ## explicit; go 1.13 github.com/go-asn1-ber/asn1-ber -# github.com/go-chi/chi/v5 v5.2.1 +# github.com/go-chi/chi/v5 v5.2.2 ## explicit; go 1.20 github.com/go-chi/chi/v5 github.com/go-chi/chi/v5/middleware