diff options
author | Don Bowman <don.waterloo@gmail.com> | 2015-08-12 21:10:00 +0000 |
---|---|---|
committer | Don Bowman <don.waterloo@gmail.com> | 2015-08-12 21:10:00 +0000 |
commit | 1cb46ede1acf4f8527e64fcae7e92672cad764b2 (patch) | |
tree | fabb54ee5f040be2a4ee5c95f87cb3e9fbf7bdea /modules/base | |
parent | 9e6bd31d76aa6d6495a2144466af78773f34d07c (diff) | |
parent | aede5cdb04fdbf74d9c602062fdece9f408e90f4 (diff) | |
download | gitea-1cb46ede1acf4f8527e64fcae7e92672cad764b2.tar.gz gitea-1cb46ede1acf4f8527e64fcae7e92672cad764b2.zip |
Merge branch 'master' of https://github.com/gogits/gogs
Conflicts:
routers/repo/download.go
Diffstat (limited to 'modules/base')
-rw-r--r-- | modules/base/template.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/modules/base/template.go b/modules/base/template.go index 1442bf0e84..0d68254561 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -20,6 +20,10 @@ import ( "github.com/gogits/gogs/modules/setting" ) +func Safe(raw string) template.HTML { + return template.HTML(raw) +} + func Str2html(raw string) template.HTML { return template.HTML(Sanitizer.Sanitize(raw)) } @@ -55,6 +59,9 @@ func ShortSha(sha1 string) string { func DetectEncoding(content []byte) (string, error) { detector := chardet.NewTextDetector() result, err := detector.DetectBest(content) + if result.Charset != "UTF-8" && len(setting.AnsiCharset) > 0 { + return setting.AnsiCharset, err + } return result.Charset, err } @@ -64,7 +71,7 @@ func ToUtf8WithErr(content []byte) (error, string) { return err, "" } - if charsetLabel == "utf8" { + if charsetLabel == "UTF-8" { return nil, string(content) } @@ -125,6 +132,7 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{ return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms" }, "AvatarLink": AvatarLink, + "Safe": Safe, "Str2html": Str2html, "TimeSince": TimeSince, "FileSize": FileSize, @@ -175,7 +183,7 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{ "Oauth2Name": Oauth2Name, "ToUtf8": ToUtf8, "EscapePound": func(str string) string { - return strings.Replace(str, "#", "%23", -1) + return strings.Replace(strings.Replace(str, "%", "%25", -1), "#", "%23", -1) }, "RenderCommitMessage": RenderCommitMessage, } |