|
|
@ -22,8 +22,7 @@ import ( |
|
|
|
"github.com/Unknwon/com" |
|
|
|
"github.com/Unknwon/com" |
|
|
|
"github.com/Unknwon/i18n" |
|
|
|
"github.com/Unknwon/i18n" |
|
|
|
"github.com/microcosm-cc/bluemonday" |
|
|
|
"github.com/microcosm-cc/bluemonday" |
|
|
|
|
|
|
|
"golang.org/x/net/html/charset" |
|
|
|
"github.com/gogits/chardet" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/gogits/gogs/modules/avatar" |
|
|
|
"github.com/gogits/gogs/modules/avatar" |
|
|
|
"github.com/gogits/gogs/modules/setting" |
|
|
|
"github.com/gogits/gogs/modules/setting" |
|
|
@ -52,13 +51,9 @@ func ShortSha(sha1 string) string { |
|
|
|
return sha1 |
|
|
|
return sha1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func DetectEncoding(content []byte) (string, error) { |
|
|
|
func DetectEncoding(content []byte) string { |
|
|
|
detector := chardet.NewTextDetector() |
|
|
|
_, name, _ := charset.DetermineEncoding(content, setting.Repository.AnsiCharset) |
|
|
|
result, err := detector.DetectBest(content) |
|
|
|
return name |
|
|
|
if result.Charset != "UTF-8" && len(setting.Repository.AnsiCharset) > 0 { |
|
|
|
|
|
|
|
return setting.Repository.AnsiCharset, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result.Charset, err |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func BasicAuthDecode(encoded string) (string, string, error) { |
|
|
|
func BasicAuthDecode(encoded string) (string, string, error) { |
|
|
|