mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Merge branch 'master' of https://github.com/gogits/gogs
Conflicts: routers/repo/download.go
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
Reference in New Issue
Block a user