diff --git a/gogs.go b/gogs.go index dfce9d526..ec49b78f2 100644 --- a/gogs.go +++ b/gogs.go @@ -16,7 +16,7 @@ import ( "github.com/gogits/gogs/pkg/setting" ) -const APP_VER = "0.11.34.0302" +const APP_VER = "0.11.35.0306" func init() { setting.AppVer = APP_VER diff --git a/templates/.VERSION b/templates/.VERSION index 0c287fcaa..ed2cfe0e0 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.11.34.0302 \ No newline at end of file +0.11.35.0306 \ No newline at end of file diff --git a/vendor/gopkg.in/macaron.v1/LICENSE b/vendor/gopkg.in/macaron.v1/LICENSE index 37ec93a14..c8a16eb2e 100644 --- a/vendor/gopkg.in/macaron.v1/LICENSE +++ b/vendor/gopkg.in/macaron.v1/LICENSE @@ -176,7 +176,7 @@ recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright 2014 The Macaron Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/vendor/gopkg.in/macaron.v1/README.md b/vendor/gopkg.in/macaron.v1/README.md index 83d247e23..b395b3893 100644 --- a/vendor/gopkg.in/macaron.v1/README.md +++ b/vendor/gopkg.in/macaron.v1/README.md @@ -61,19 +61,20 @@ There are already many [middlewares](https://github.com/go-macaron) to simplify - [bindata](https://github.com/go-macaron/bindata) - Embed binary data as static and template files - [toolbox](https://github.com/go-macaron/toolbox) - Health check, pprof, profile and statistic services - [oauth2](https://github.com/go-macaron/oauth2) - OAuth 2.0 backend +- [authz](https://github.com/go-macaron/authz) - ACL/RBAC/ABAC authorization based on Casbin - [switcher](https://github.com/go-macaron/switcher) - Multiple-site support - [method](https://github.com/go-macaron/method) - HTTP method override - [permissions2](https://github.com/xyproto/permissions2) - Cookies, users and permissions - [renders](https://github.com/go-macaron/renders) - Beego-like render engine(Macaron has built-in template engine, this is another option) +- [piwik](https://github.com/veecue/piwik-middleware) - Server-side piwik analytics ## Use Cases - [Gogs](https://gogs.io): A painless self-hosted Git Service -- [Grafana](http://grafana.org/): The tool for beautiful monitoring and metric analytics & dashboards +- [Grafana](http://grafana.org/): The open platform for beautiful analytics and monitoring - [Peach](https://peachdocs.org): A modern web documentation server - [Go Walker](https://gowalker.org): Go online API documentation - [Switch](https://gopm.io): Gopm registry -- [YouGam](http://yougam.com): Online Forum - [Critical Stack Intel](https://intel.criticalstack.com/): A 100% free intel marketplace from Critical Stack, Inc. ## Getting Help @@ -81,7 +82,6 @@ There are already many [middlewares](https://github.com/go-macaron) to simplify - [API Reference](https://gowalker.org/gopkg.in/macaron.v1) - [Documentation](https://go-macaron.com) - [FAQs](https://go-macaron.com/docs/faqs) -- [![Join the chat at https://gitter.im/Unknwon/macaron](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-macaron/macaron?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ## Credits diff --git a/vendor/gopkg.in/macaron.v1/context.go b/vendor/gopkg.in/macaron.v1/context.go index dffc50cf6..94a8c45d7 100644 --- a/vendor/gopkg.in/macaron.v1/context.go +++ b/vendor/gopkg.in/macaron.v1/context.go @@ -268,6 +268,11 @@ func (ctx *Context) SetParams(name, val string) { ctx.params[name] = val } +// ReplaceAllParams replace all current params with given params +func (ctx *Context) ReplaceAllParams(params Params) { + ctx.params = params; +} + // ParamsEscape returns escapred params result. // e.g. ctx.ParamsEscape(":uname") func (ctx *Context) ParamsEscape(name string) string { diff --git a/vendor/gopkg.in/macaron.v1/macaron.go b/vendor/gopkg.in/macaron.v1/macaron.go index 403bcb82f..bd1b5a317 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.1.0219" +const _VERSION = "1.3.1.0306" 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 ab54f56c0..9133948f9 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 21b00ec98..df593d669 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 } @@ -118,7 +118,7 @@ func (r *Route) Name(name string) { if len(name) == 0 { panic("route name cannot be empty") } else if r.router.namedRoutes[name] != nil { - panic("route with given name already exists") + panic("route with given name already exists: " + name) } r.router.namedRoutes[name] = r.leaf } @@ -288,7 +288,14 @@ func (r *Router) SetHandlerWrapper(f func(Handler) Handler) { func (r *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request) { if t, ok := r.routers[req.Method]; ok { - h, p, ok := t.Match(req.URL.Path) + // Fast match for static routes + leaf := r.getLeaf(req.Method, req.URL.Path) + if leaf != nil { + leaf.handle(rw, req, nil) + return + } + + h, p, ok := t.Match(req.URL.EscapedPath()) if ok { if splat, ok := p["*0"]; ok { p["*"] = splat // Easy name. @@ -334,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...) } diff --git a/vendor/gopkg.in/macaron.v1/tree.go b/vendor/gopkg.in/macaron.v1/tree.go index 8bba72fb3..c351b9452 100644 --- a/vendor/gopkg.in/macaron.v1/tree.go +++ b/vendor/gopkg.in/macaron.v1/tree.go @@ -261,6 +261,10 @@ func (t *Tree) Add(pattern string, handle Handle) *Leaf { } func (t *Tree) matchLeaf(globLevel int, url string, params Params) (Handle, bool) { + url, err := PathUnescape(url) + if err != nil { + return nil, false + } for i := 0; i < len(t.leaves); i++ { switch t.leaves[i].typ { case _PATTERN_STATIC: @@ -300,16 +304,20 @@ func (t *Tree) matchLeaf(globLevel int, url string, params Params) (Handle, bool } func (t *Tree) matchSubtree(globLevel int, segment, url string, params Params) (Handle, bool) { + unescapedSegment, err := PathUnescape(segment) + if err != nil { + return nil, false + } for i := 0; i < len(t.subtrees); i++ { switch t.subtrees[i].typ { case _PATTERN_STATIC: - if t.subtrees[i].pattern == segment { + if t.subtrees[i].pattern == unescapedSegment { if handle, ok := t.subtrees[i].matchNextSegment(globLevel, url, params); ok { return handle, true } } case _PATTERN_REGEXP: - results := t.subtrees[i].reg.FindStringSubmatch(segment) + results := t.subtrees[i].reg.FindStringSubmatch(unescapedSegment) if len(results)-1 != len(t.subtrees[i].wildcards) { break } @@ -322,12 +330,12 @@ func (t *Tree) matchSubtree(globLevel int, segment, url string, params Params) ( } case _PATTERN_HOLDER: if handle, ok := t.subtrees[i].matchNextSegment(globLevel+1, url, params); ok { - params[t.subtrees[i].wildcards[0]] = segment + params[t.subtrees[i].wildcards[0]] = unescapedSegment return handle, true } case _PATTERN_MATCH_ALL: if handle, ok := t.subtrees[i].matchNextSegment(globLevel+1, url, params); ok { - params["*"+com.ToStr(globLevel)] = segment + params["*"+com.ToStr(globLevel)] = unescapedSegment return handle, true } } @@ -335,19 +343,22 @@ func (t *Tree) matchSubtree(globLevel int, segment, url string, params Params) ( if len(t.leaves) > 0 { leaf := t.leaves[len(t.leaves)-1] + unescapedURL, err := PathUnescape(segment + "/" + url) + if err != nil { + return nil, false + } if leaf.typ == _PATTERN_PATH_EXT { - url = segment + "/" + url - j := strings.LastIndex(url, ".") + j := strings.LastIndex(unescapedURL, ".") if j > -1 { - params[":path"] = url[:j] - params[":ext"] = url[j+1:] + params[":path"] = unescapedURL[:j] + params[":ext"] = unescapedURL[j+1:] } else { - params[":path"] = url + params[":path"] = unescapedURL } return leaf.handle, true } else if leaf.typ == _PATTERN_MATCH_ALL { - params["*"] = segment + "/" + url - params["*"+com.ToStr(globLevel)] = segment + "/" + url + params["*"] = unescapedURL + params["*"+com.ToStr(globLevel)] = unescapedURL return leaf.handle, true } } diff --git a/vendor/gopkg.in/macaron.v1/util_go17.go b/vendor/gopkg.in/macaron.v1/util_go17.go new file mode 100644 index 000000000..a80c696c7 --- /dev/null +++ b/vendor/gopkg.in/macaron.v1/util_go17.go @@ -0,0 +1,25 @@ +// +build !go1.8 + +// Copyright 2017 The Macaron Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"): you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +package macaron + +import "net/url" + +// PathUnescape unescapes a path. Ideally, this function would use +// url.PathUnescape(..), but the function was not introduced until go1.8. +func PathUnescape(s string) (string, error) { + return url.QueryUnescape(s) +} diff --git a/vendor/gopkg.in/macaron.v1/util_go18.go b/vendor/gopkg.in/macaron.v1/util_go18.go new file mode 100644 index 000000000..d5eb1dfb2 --- /dev/null +++ b/vendor/gopkg.in/macaron.v1/util_go18.go @@ -0,0 +1,24 @@ +// +build go1.8 + +// Copyright 2017 The Macaron Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"): you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +package macaron + +import "net/url" + +// PathUnescape unescapes a path. +func PathUnescape(s string) (string, error) { + return url.PathUnescape(s) +} diff --git a/vendor/vendor.json b/vendor/vendor.json index 34b860fd4..0d71b62dc 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -597,10 +597,10 @@ "revisionTime": "2016-08-08T14:54:09Z" }, { - "checksumSHA1": "qM9ubEa57g4oNa6JLFQ+e1TCMno=", + "checksumSHA1": "7c6yCe2PjyV+/qWiPBWUf+j+1us=", "path": "gopkg.in/macaron.v1", - "revision": "a325110f8b392bce3e5cdeb8c44bf98078ada3be", - "revisionTime": "2017-02-19T20:49:11Z" + "revision": "c1be95e6d21e769e44e1ec33cec9da5837861c10", + "revisionTime": "2018-03-06T06:20:08Z" }, { "checksumSHA1": "6QPjE+qflEBHg+JPJd9e4iQuRAk=",