1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-05 09:55:20 +02:00
Conflicts:
	routers/repo/download.go
This commit is contained in:
Don Bowman 2015-08-12 21:10:00 +00:00
commit 1cb46ede1a
250 changed files with 13805 additions and 6717 deletions

View file

@ -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,
}