From f5b43a615c7bc62f9f6d50c6925f851938245e1d Mon Sep 17 00:00:00 2001 From: zeripath Date: Sat, 12 Jan 2019 19:57:50 +0000 Subject: [PATCH] When redirecting clean the path to avoid redirecting to //www.othersite.com (#5669) (#5703) Fix #5627 Signed-off-by: Andrew Thornton --- modules/public/public.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/public/public.go b/modules/public/public.go index f03f8fcc1..2e004536f 100644 --- a/modules/public/public.go +++ b/modules/public/public.go @@ -117,7 +117,7 @@ func (opts *Options) handle(ctx *macaron.Context, log *log.Logger, opt *Options) if fi.IsDir() { // 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) + http.Redirect(ctx.Resp, ctx.Req.Request, path.Clean(ctx.Req.URL.Path+"/"), http.StatusFound) return true }