From 2c8cb5693ee650b4352926cf178d5d24786698ff Mon Sep 17 00:00:00 2001 From: nkbai Date: Fri, 27 Nov 2015 12:10:39 +0800 Subject: [PATCH] =?UTF-8?q?windows=E4=B8=8B=E9=9D=99=E6=80=81=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=98=A0=E5=B0=84=E6=89=BE=E4=B8=8D=E5=88=B0=E9=97=AE?= =?UTF-8?q?=E9=A2=98,=20path.Clean=E5=92=8Cfilepath.Clean=E6=98=AF?= =?UTF-8?q?=E6=9C=89=E5=8C=BA=E5=88=AB=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- staticfile.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/staticfile.go b/staticfile.go index de530b0c..56c5fc08 100644 --- a/staticfile.go +++ b/staticfile.go @@ -18,20 +18,18 @@ import ( "net/http" "os" "path" - "path/filepath" "strconv" "strings" - "github.com/astaxie/beego/context" "github.com/astaxie/beego/utils" ) func serverStaticRouter(ctx *context.Context) { + if ctx.Input.Method() != "GET" && ctx.Input.Method() != "HEAD" { return } - requestPath := filepath.Clean(ctx.Input.Request.URL.Path) - + requestPath := path.Clean(ctx.Input.Request.URL.Path) // special processing : favicon.ico/robots.txt can be in any static dir if requestPath == "/favicon.ico" || requestPath == "/robots.txt" { file := path.Join(".", requestPath)