diff options
Diffstat (limited to 'vendor/gitea.com')
-rw-r--r-- | vendor/gitea.com/macaron/gzip/.drone.yml | 8 | ||||
-rw-r--r-- | vendor/gitea.com/macaron/gzip/go.mod | 4 | ||||
-rw-r--r-- | vendor/gitea.com/macaron/gzip/go.sum | 18 | ||||
-rw-r--r-- | vendor/gitea.com/macaron/gzip/gzip.go | 10 | ||||
-rw-r--r-- | vendor/gitea.com/macaron/macaron/.drone.yml | 4 | ||||
-rw-r--r-- | vendor/gitea.com/macaron/macaron/README.md | 8 | ||||
-rw-r--r-- | vendor/gitea.com/macaron/macaron/context.go | 9 | ||||
-rw-r--r-- | vendor/gitea.com/macaron/macaron/recovery.go | 2 | ||||
-rw-r--r-- | vendor/gitea.com/macaron/macaron/render.go | 15 | ||||
-rw-r--r-- | vendor/gitea.com/macaron/macaron/response_writer.go | 14 | ||||
-rw-r--r-- | vendor/gitea.com/macaron/macaron/return_handler.go | 4 | ||||
-rw-r--r-- | vendor/gitea.com/macaron/macaron/static.go | 17 |
12 files changed, 81 insertions, 32 deletions
diff --git a/vendor/gitea.com/macaron/gzip/.drone.yml b/vendor/gitea.com/macaron/gzip/.drone.yml index e55afaac04..087a19664c 100644 --- a/vendor/gitea.com/macaron/gzip/.drone.yml +++ b/vendor/gitea.com/macaron/gzip/.drone.yml @@ -1,9 +1,9 @@ kind: pipeline -name: go1-1-2 +name: go1-14 steps: - name: test - image: golang:1.12 + image: golang:1.14 environment: GOPROXY: https://goproxy.cn commands: @@ -12,11 +12,11 @@ steps: --- kind: pipeline -name: go1-1-3 +name: go1-15 steps: - name: test - image: golang:1.13 + image: golang:1.15 environment: GOPROXY: https://goproxy.cn commands: diff --git a/vendor/gitea.com/macaron/gzip/go.mod b/vendor/gitea.com/macaron/gzip/go.mod index e66cacaa30..877ee7e37a 100644 --- a/vendor/gitea.com/macaron/gzip/go.mod +++ b/vendor/gitea.com/macaron/gzip/go.mod @@ -3,7 +3,9 @@ module gitea.com/macaron/gzip go 1.12 require ( - gitea.com/macaron/macaron v1.3.3-0.20190821202302-9646c0587edb + gitea.com/macaron/macaron v1.5.0 github.com/klauspost/compress v1.9.2 github.com/stretchr/testify v1.4.0 + golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a // indirect + gopkg.in/ini.v1 v1.60.1 // indirect ) diff --git a/vendor/gitea.com/macaron/gzip/go.sum b/vendor/gitea.com/macaron/gzip/go.sum index 292be5f957..b34055da3e 100644 --- a/vendor/gitea.com/macaron/gzip/go.sum +++ b/vendor/gitea.com/macaron/gzip/go.sum @@ -1,7 +1,7 @@ -gitea.com/macaron/inject v0.0.0-20190803172902-8375ba841591 h1:UbCTjPcLrNxR9LzKDjQBMT2zoxZuEnca1pZCpgeMuhQ= -gitea.com/macaron/inject v0.0.0-20190803172902-8375ba841591/go.mod h1:h6E4kLao1Yko6DOU6QDnQPcuoNzvbZqzj2mtPcEn1aM= -gitea.com/macaron/macaron v1.3.3-0.20190821202302-9646c0587edb h1:amL0md6orTj1tXY16ANzVU9FmzQB+W7aJwp8pVDbrmA= -gitea.com/macaron/macaron v1.3.3-0.20190821202302-9646c0587edb/go.mod h1:0coI+mSPSwbsyAbOuFllVS38awuk9mevhLD52l50Gjs= +gitea.com/macaron/inject v0.0.0-20190805023432-d4c86e31027a h1:aOKEXkDTnh4euoH0so/THLXeHtQuqHmDPb1xEk6Ehok= +gitea.com/macaron/inject v0.0.0-20190805023432-d4c86e31027a/go.mod h1:h6E4kLao1Yko6DOU6QDnQPcuoNzvbZqzj2mtPcEn1aM= +gitea.com/macaron/macaron v1.5.0 h1:TvWEcHw1/zaHlo0GTuKEukLh3A99+QsU2mjBrXLXjVQ= +gitea.com/macaron/macaron v1.5.0/go.mod h1:P7hfDbQjcW22lkYkXlxdRIfWOXxH2+K4EogN4Q0UlLY= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -17,17 +17,21 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 h1:Jpy1PXuP99tXNrhbq2BaPz9B+jNAvH1JPQQpG/9GCXY= github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w= +github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 h1:WN9BUFbdyOsSH/XohnWpXOlq9NBD5sGAB2FciQMUEe8= github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e h1:GSGeB9EAKY2spCABz6xOX5DbxZEXolK+nBSvmsQwRjM= -github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM= +github.com/unknwon/com v1.0.1 h1:3d1LTxD+Lnf3soQiD4Cp/0BRB+Rsa/+RTvz8GMMzIXs= +github.com/unknwon/com v1.0.1/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -38,5 +42,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/ini.v1 v1.44.0 h1:YRJzTUp0kSYWUVFF5XAbDFfyiqwsl0Vb9R8TVP5eRi0= gopkg.in/ini.v1 v1.44.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.60.1 h1:P5y5shSkb0CFe44qEeMBgn8JLow09MP17jlJHanke5g= +gopkg.in/ini.v1 v1.60.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/gitea.com/macaron/gzip/gzip.go b/vendor/gitea.com/macaron/gzip/gzip.go index 9573d167ab..cd93e03f68 100644 --- a/vendor/gitea.com/macaron/gzip/gzip.go +++ b/vendor/gitea.com/macaron/gzip/gzip.go @@ -6,6 +6,7 @@ package gzip import ( "bufio" + "errors" "fmt" "io" "net" @@ -331,6 +332,15 @@ func (proxy *ProxyResponseWriter) Flush() { proxy.internal.Flush() } +// Push implements http.Pusher for HTTP/2 Push purposes +func (proxy *ProxyResponseWriter) Push(target string, opts *http.PushOptions) error { + pusher, ok := proxy.internal.(http.Pusher) + if !ok { + return errors.New("the ResponseWriter doesn't support the Pusher interface") + } + return pusher.Push(target, opts) +} + // Hijack implements http.Hijacker. If the underlying ResponseWriter is a // Hijacker, its Hijack method is returned. Otherwise an error is returned. func (proxy *ProxyResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { diff --git a/vendor/gitea.com/macaron/macaron/.drone.yml b/vendor/gitea.com/macaron/macaron/.drone.yml index 06ecc018e3..06a3e7d853 100644 --- a/vendor/gitea.com/macaron/macaron/.drone.yml +++ b/vendor/gitea.com/macaron/macaron/.drone.yml @@ -3,7 +3,9 @@ name: default steps: - name: test - image: golang:1.12 + image: golang:1.13 + environment: + GOPROXY: https://goproxy.cn commands: - go get -u - go build -v diff --git a/vendor/gitea.com/macaron/macaron/README.md b/vendor/gitea.com/macaron/macaron/README.md index 97b782ed87..34830c8b17 100644 --- a/vendor/gitea.com/macaron/macaron/README.md +++ b/vendor/gitea.com/macaron/macaron/README.md @@ -1,5 +1,9 @@ -Macaron [![Build Status](https://travis-ci.org/go-macaron/macaron.svg?branch=v1)](https://travis-ci.org/go-macaron/macaron) -======================= +# Macaron + +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/go-macaron/macaron/Go?logo=github&style=for-the-badge)](https://github.com/go-macaron/macaron/actions?query=workflow%3AGo) +[![codecov](https://img.shields.io/codecov/c/github/go-macaron/macaron/master?logo=codecov&style=for-the-badge)](https://codecov.io/gh/go-macaron/macaron) +[![GoDoc](https://img.shields.io/badge/GoDoc-Reference-blue?style=for-the-badge&logo=go)](https://pkg.go.dev/gopkg.in/macaron.v1?tab=doc) +[![Sourcegraph](https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg?style=for-the-badge&logo=sourcegraph)](https://sourcegraph.com/github.com/go-macaron/macaron) ![Macaron Logo](https://raw.githubusercontent.com/go-macaron/macaron/v1/macaronlogo.png) diff --git a/vendor/gitea.com/macaron/macaron/context.go b/vendor/gitea.com/macaron/macaron/context.go index a3f2c69e03..35a7e7017c 100644 --- a/vendor/gitea.com/macaron/macaron/context.go +++ b/vendor/gitea.com/macaron/macaron/context.go @@ -193,9 +193,9 @@ func (ctx *Context) parseForm() { contentType := ctx.Req.Header.Get(_CONTENT_TYPE) if (ctx.Req.Method == "POST" || ctx.Req.Method == "PUT") && len(contentType) > 0 && strings.Contains(contentType, "multipart/form-data") { - ctx.Req.ParseMultipartForm(MaxMemory) + _ = ctx.Req.ParseMultipartForm(MaxMemory) } else { - ctx.Req.ParseForm() + _ = ctx.Req.ParseForm() } } @@ -260,6 +260,11 @@ func (ctx *Context) Params(name string) string { return ctx.params[name] } +// AllParams returns all params. +func (ctx *Context) AllParams() Params { + return ctx.params +} + // SetParams sets value of param with given name. func (ctx *Context) SetParams(name, val string) { if name != "*" && !strings.HasPrefix(name, ":") { diff --git a/vendor/gitea.com/macaron/macaron/recovery.go b/vendor/gitea.com/macaron/macaron/recovery.go index 49c3096d64..1d301f7218 100644 --- a/vendor/gitea.com/macaron/macaron/recovery.go +++ b/vendor/gitea.com/macaron/macaron/recovery.go @@ -153,7 +153,7 @@ func Recovery() Handler { res.WriteHeader(http.StatusInternalServerError) if nil != body { - res.Write(body) + _, _ = res.Write(body) } } }() diff --git a/vendor/gitea.com/macaron/macaron/render.go b/vendor/gitea.com/macaron/macaron/render.go index 6f2e93f21b..04687c4f40 100644 --- a/vendor/gitea.com/macaron/macaron/render.go +++ b/vendor/gitea.com/macaron/macaron/render.go @@ -36,7 +36,6 @@ import ( const ( _CONTENT_TYPE = "Content-Type" - _CONTENT_LENGTH = "Content-Length" _CONTENT_BINARY = "application/octet-stream" _CONTENT_JSON = "application/json" _CONTENT_HTML = "text/html" @@ -200,7 +199,7 @@ func NewTemplateFileSystem(opt RenderOptions, omitData bool) TplFileSystem { lastDir := dirs[len(dirs)-1] // We still walk the last (original) directory because it's non-sense we load templates not exist in original directory. - if err = filepath.Walk(lastDir, func(path string, info os.FileInfo, err error) error { + if err = filepath.Walk(lastDir, func(path string, info os.FileInfo, _ error) error { r, err := filepath.Rel(lastDir, path) if err != nil { return err @@ -458,9 +457,9 @@ func (r *TplRender) JSON(status int, v interface{}) { r.Header().Set(_CONTENT_TYPE, _CONTENT_JSON+r.CompiledCharset) r.WriteHeader(status) if len(r.Opt.PrefixJSON) > 0 { - r.Write(r.Opt.PrefixJSON) + _, _ = r.Write(r.Opt.PrefixJSON) } - r.Write(result) + _, _ = r.Write(result) } func (r *TplRender) JSONString(v interface{}) (string, error) { @@ -494,9 +493,9 @@ func (r *TplRender) XML(status int, v interface{}) { r.Header().Set(_CONTENT_TYPE, _CONTENT_XML+r.CompiledCharset) r.WriteHeader(status) if len(r.Opt.PrefixXML) > 0 { - r.Write(r.Opt.PrefixXML) + _, _ = r.Write(r.Opt.PrefixXML) } - r.Write(result) + _, _ = r.Write(result) } func (r *TplRender) data(status int, contentType string, v []byte) { @@ -504,7 +503,7 @@ func (r *TplRender) data(status int, contentType string, v []byte) { r.Header().Set(_CONTENT_TYPE, contentType) } r.WriteHeader(status) - r.Write(v) + _, _ = r.Write(v) } func (r *TplRender) RawData(status int, v []byte) { @@ -612,7 +611,7 @@ func (r *TplRender) HTMLString(name string, data interface{}, htmlOpt ...HTMLOpt func (r *TplRender) Error(status int, message ...string) { r.WriteHeader(status) if len(message) > 0 { - r.Write([]byte(message[0])) + _, _ = r.Write([]byte(message[0])) } } diff --git a/vendor/gitea.com/macaron/macaron/response_writer.go b/vendor/gitea.com/macaron/macaron/response_writer.go index 9133948f9b..eeb35f642e 100644 --- a/vendor/gitea.com/macaron/macaron/response_writer.go +++ b/vendor/gitea.com/macaron/macaron/response_writer.go @@ -16,7 +16,7 @@ package macaron import ( "bufio" - "fmt" + "errors" "net" "net/http" ) @@ -27,6 +27,7 @@ import ( type ResponseWriter interface { http.ResponseWriter http.Flusher + http.Pusher // Status returns the status code of the response or 0 if the response has not been written. Status() int // Written returns whether or not the ResponseWriter has been written. @@ -91,11 +92,12 @@ func (rw *responseWriter) Before(before BeforeFunc) { func (rw *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { hijacker, ok := rw.ResponseWriter.(http.Hijacker) if !ok { - return nil, nil, fmt.Errorf("the ResponseWriter doesn't support the Hijacker interface") + return nil, nil, errors.New("the ResponseWriter doesn't support the Hijacker interface") } return hijacker.Hijack() } +//nolint func (rw *responseWriter) CloseNotify() <-chan bool { return rw.ResponseWriter.(http.CloseNotifier).CloseNotify() } @@ -112,3 +114,11 @@ func (rw *responseWriter) Flush() { flusher.Flush() } } + +func (rw *responseWriter) Push(target string, opts *http.PushOptions) error { + pusher, ok := rw.ResponseWriter.(http.Pusher) + if !ok { + return errors.New("the ResponseWriter doesn't support the Pusher interface") + } + return pusher.Push(target, opts) +} diff --git a/vendor/gitea.com/macaron/macaron/return_handler.go b/vendor/gitea.com/macaron/macaron/return_handler.go index 2e37c78a32..10b2c2283f 100644 --- a/vendor/gitea.com/macaron/macaron/return_handler.go +++ b/vendor/gitea.com/macaron/macaron/return_handler.go @@ -68,9 +68,9 @@ func defaultReturnHandler() ReturnHandler { respVal = respVal.Elem() } if isByteSlice(respVal) { - resp.Write(respVal.Bytes()) + _, _ = resp.Write(respVal.Bytes()) } else { - resp.Write([]byte(respVal.String())) + _, _ = resp.Write([]byte(respVal.String())) } } } diff --git a/vendor/gitea.com/macaron/macaron/static.go b/vendor/gitea.com/macaron/macaron/static.go index 60c521110e..04d91d8c9a 100644 --- a/vendor/gitea.com/macaron/macaron/static.go +++ b/vendor/gitea.com/macaron/macaron/static.go @@ -17,6 +17,7 @@ package macaron import ( "encoding/base64" + "fmt" "log" "net/http" "path" @@ -148,9 +149,15 @@ func staticHandler(ctx *Context, log *log.Logger, opt StaticOptions) bool { // Try to serve index file if fi.IsDir() { + redirPath := path.Clean(ctx.Req.URL.Path) + // path.Clean removes the trailing slash, so we need to add it back when + // the original path has it. + if strings.HasSuffix(ctx.Req.URL.Path, "/") { + redirPath = redirPath + "/" + } // Redirect if missing trailing slash. - if !strings.HasSuffix(ctx.Req.URL.Path, "/") { - http.Redirect(ctx.Resp, ctx.Req.Request, ctx.Req.URL.Path+"/", http.StatusFound) + if !strings.HasSuffix(redirPath, "/") { + http.Redirect(ctx.Resp, ctx.Req.Request, redirPath+"/", http.StatusFound) return true } @@ -177,8 +184,12 @@ func staticHandler(ctx *Context, log *log.Logger, opt StaticOptions) bool { } if opt.ETag { - tag := GenerateETag(string(fi.Size()), fi.Name(), fi.ModTime().UTC().Format(http.TimeFormat)) + tag := `"` + GenerateETag(fmt.Sprintf("%d", fi.Size()), fi.Name(), fi.ModTime().UTC().Format(http.TimeFormat)) + `"` ctx.Resp.Header().Set("ETag", tag) + if ctx.Req.Header.Get("If-None-Match") == tag { + ctx.Resp.WriteHeader(http.StatusNotModified) + return true + } } http.ServeContent(ctx.Resp, ctx.Req.Request, file, fi.ModTime(), f) |