From 7f9598141bd7b0200d9342f01243228eab3061ba Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 24 Nov 2015 18:49:34 -0500 Subject: [PATCH] fix #2020 --- modules/base/tool.go | 4 ++-- modules/middleware/auth.go | 2 +- modules/template/template.go | 2 +- routers/user/auth.go | 2 +- routers/user/setting.go | 2 +- templates/base/head.tmpl | 4 ++-- templates/status/404.tmpl | 2 +- templates/status/500.tmpl | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/base/tool.go b/modules/base/tool.go index 78983b3611..b1d945117c 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -31,8 +31,8 @@ import ( var Sanitizer = bluemonday.UGCPolicy().AllowAttrs("class").Matching(regexp.MustCompile(`[\p{L}\p{N}\s\-_',:\[\]!\./\\\(\)&]*`)).OnElements("code") -// Encode string to md5 hex value. -func EncodeMd5(str string) string { +// EncodeMD5 encodes string to md5 hex value. +func EncodeMD5(str string) string { m := md5.New() m.Write([]byte(str)) return hex.EncodeToString(m.Sum(nil)) diff --git a/modules/middleware/auth.go b/modules/middleware/auth.go index 4b9531571b..078bdfdc5b 100644 --- a/modules/middleware/auth.go +++ b/modules/middleware/auth.go @@ -54,7 +54,7 @@ func AutoSignIn(ctx *Context) (bool, error) { } if val, _ := ctx.GetSuperSecureCookie( - base.EncodeMd5(u.Rands+u.Passwd), setting.CookieRememberName); val != u.Name { + base.EncodeMD5(u.Rands+u.Passwd), setting.CookieRememberName); val != u.Name { return false, nil } diff --git a/modules/template/template.go b/modules/template/template.go index 37c7d79351..c408ac8a26 100644 --- a/modules/template/template.go +++ b/modules/template/template.go @@ -88,7 +88,7 @@ var Funcs template.FuncMap = map[string]interface{}{ "DiffLineTypeToStr": DiffLineTypeToStr, "Sha1": Sha1, "ShortSha": base.ShortSha, - "Md5": base.EncodeMd5, + "MD5": base.EncodeMD5, "ActionContent2Commits": ActionContent2Commits, "ToUtf8": ToUtf8, "EscapePound": func(str string) string { diff --git a/routers/user/auth.go b/routers/user/auth.go index 24ed3673e8..3f37b09059 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -70,7 +70,7 @@ func SignInPost(ctx *middleware.Context, form auth.SignInForm) { if form.Remember { days := 86400 * setting.LogInRememberDays ctx.SetCookie(setting.CookieUserName, u.Name, days, setting.AppSubUrl) - ctx.SetSuperSecureCookie(base.EncodeMd5(u.Rands+u.Passwd), + ctx.SetSuperSecureCookie(base.EncodeMD5(u.Rands+u.Passwd), setting.CookieRememberName, u.Name, days, setting.AppSubUrl) } diff --git a/routers/user/setting.go b/routers/user/setting.go index 53b7fdf929..2e825cf56f 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -79,7 +79,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) { ctx.User.Email = form.Email ctx.User.Website = form.Website ctx.User.Location = form.Location - ctx.User.Avatar = base.EncodeMd5(form.Gravatar) + ctx.User.Avatar = base.EncodeMD5(form.Gravatar) ctx.User.AvatarEmail = form.Gravatar if err := models.UpdateUser(ctx.User); err != nil { ctx.Handle(500, "UpdateUser", err) diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 171e6fde01..d5513280a0 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -21,11 +21,11 @@ - + - + {{if .Title}}{{.Title}} - {{end}}{{AppName}} diff --git a/templates/status/404.tmpl b/templates/status/404.tmpl index b9874c5f17..a1b632df2a 100644 --- a/templates/status/404.tmpl +++ b/templates/status/404.tmpl @@ -3,7 +3,7 @@

404


-

Application Version: {{AppVer}}

+ {{if .ShowFooterVersion}}

Application Version: {{AppVer}}

{{end}}

If you think this is an error, please open an issue on GitHub.

{{template "base/footer" .}} diff --git a/templates/status/500.tmpl b/templates/status/500.tmpl index ac2b4be71f..519a6f60f6 100644 --- a/templates/status/500.tmpl +++ b/templates/status/500.tmpl @@ -4,6 +4,6 @@

{{if .ErrorMsg}}

An error has occurred : {{.ErrorMsg}}

{{end}} -

Application Version: {{AppVer}}

+ {{if .ShowFooterVersion}}

Application Version: {{AppVer}}

{{end}} {{template "base/footer" .}}