diff options
author | Gabriel Silva Simões <simoes.sgabriel@gmail.com> | 2019-02-05 20:58:55 -0500 |
---|---|---|
committer | techknowlogick <matti@mdranta.net> | 2019-02-05 20:58:55 -0500 |
commit | 3b7f41f9f7bbd3d19ce5a6b667b5c1f56c2b1b51 (patch) | |
tree | 02faf1bad6fce7f2b4357e7a4c705c6f8069fd23 /vendor | |
parent | 4a747aef7b24970a199f246c22974f7e1ba31382 (diff) | |
download | gitea-3b7f41f9f7bbd3d19ce5a6b667b5c1f56c2b1b51.tar.gz gitea-3b7f41f9f7bbd3d19ce5a6b667b5c1f56c2b1b51.zip |
Fix serving of raw wiki files other than .md (#5814)
* Fix serving of raw wiki files other than .md
Closes #4690.
Closes #4395.
Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com>
* Simplify code at routers/repo/wiki.go
Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com>
* Add more files to user2/repo1.wiki for testing
Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com>
* Update macaron to v1.3.2
Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com>
* Add tests for WikiRaw
Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com>
* Fix NewResponseWriter usage due to macaron update
Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com>
* Add raw to reserved wiki names
Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com>
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/gopkg.in/macaron.v1/context.go | 4 | ||||
-rw-r--r-- | vendor/gopkg.in/macaron.v1/macaron.go | 4 | ||||
-rw-r--r-- | vendor/gopkg.in/macaron.v1/response_writer.go | 13 | ||||
-rw-r--r-- | vendor/gopkg.in/macaron.v1/router.go | 5 |
4 files changed, 16 insertions, 10 deletions
diff --git a/vendor/gopkg.in/macaron.v1/context.go b/vendor/gopkg.in/macaron.v1/context.go index 94a8c45d7d..063f9e0148 100644 --- a/vendor/gopkg.in/macaron.v1/context.go +++ b/vendor/gopkg.in/macaron.v1/context.go @@ -262,7 +262,7 @@ func (ctx *Context) Params(name string) string { // SetParams sets value of param with given name. func (ctx *Context) SetParams(name, val string) { - if !strings.HasPrefix(name, ":") { + if name != "*" && !strings.HasPrefix(name, ":") { name = ":" + name } ctx.params[name] = val @@ -270,7 +270,7 @@ func (ctx *Context) SetParams(name, val string) { // ReplaceAllParams replace all current params with given params func (ctx *Context) ReplaceAllParams(params Params) { - ctx.params = params; + ctx.params = params } // ParamsEscape returns escapred params result. diff --git a/vendor/gopkg.in/macaron.v1/macaron.go b/vendor/gopkg.in/macaron.v1/macaron.go index 5926e61368..715076ac13 100644 --- a/vendor/gopkg.in/macaron.v1/macaron.go +++ b/vendor/gopkg.in/macaron.v1/macaron.go @@ -32,7 +32,7 @@ import ( "github.com/go-macaron/inject" ) -const _VERSION = "1.2.4.1123" +const _VERSION = "1.3.2.1216" func Version() string { return _VERSION @@ -194,7 +194,7 @@ func (m *Macaron) createContext(rw http.ResponseWriter, req *http.Request) *Cont index: 0, Router: m.Router, Req: Request{req}, - Resp: NewResponseWriter(rw), + Resp: NewResponseWriter(req.Method, rw), Render: &DummyRender{rw}, Data: make(map[string]interface{}), } diff --git a/vendor/gopkg.in/macaron.v1/response_writer.go b/vendor/gopkg.in/macaron.v1/response_writer.go index ab54f56c03..9133948f9b 100644 --- a/vendor/gopkg.in/macaron.v1/response_writer.go +++ b/vendor/gopkg.in/macaron.v1/response_writer.go @@ -42,11 +42,12 @@ type ResponseWriter interface { type BeforeFunc func(ResponseWriter) // NewResponseWriter creates a ResponseWriter that wraps an http.ResponseWriter -func NewResponseWriter(rw http.ResponseWriter) ResponseWriter { - return &responseWriter{rw, 0, 0, nil} +func NewResponseWriter(method string, rw http.ResponseWriter) ResponseWriter { + return &responseWriter{method, rw, 0, 0, nil} } type responseWriter struct { + method string http.ResponseWriter status int size int @@ -59,13 +60,15 @@ func (rw *responseWriter) WriteHeader(s int) { rw.status = s } -func (rw *responseWriter) Write(b []byte) (int, error) { +func (rw *responseWriter) Write(b []byte) (size int, err error) { if !rw.Written() { // The status will be StatusOK if WriteHeader has not been called yet rw.WriteHeader(http.StatusOK) } - size, err := rw.ResponseWriter.Write(b) - rw.size += size + if rw.method != "HEAD" { + size, err = rw.ResponseWriter.Write(b) + rw.size += size + } return size, err } diff --git a/vendor/gopkg.in/macaron.v1/router.go b/vendor/gopkg.in/macaron.v1/router.go index 950c5bcb09..df593d669a 100644 --- a/vendor/gopkg.in/macaron.v1/router.go +++ b/vendor/gopkg.in/macaron.v1/router.go @@ -96,7 +96,7 @@ func NewRouter() *Router { } // SetAutoHead sets the value who determines whether add HEAD method automatically -// when GET method is added. Combo router will not be affected by this value. +// when GET method is added. func (r *Router) SetAutoHead(v bool) { r.autoHead = v } @@ -341,6 +341,9 @@ func (cr *ComboRouter) route(fn func(string, ...Handler) *Route, method string, } func (cr *ComboRouter) Get(h ...Handler) *ComboRouter { + if cr.router.autoHead { + cr.Head(h...) + } return cr.route(cr.router.Get, "GET", h...) } |