aboutsummaryrefslogtreecommitdiffstats
path: root/modules/base
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-12-25 05:45:07 -0500
committerUnknwon <u@gogs.io>2015-12-25 05:45:07 -0500
commit93f03707a789a4d538c945c9838fa4ec4d3ef15c (patch)
treecdffa6724be6466da634e69abc03ab105e6f7ae1 /modules/base
parent85af36332b89a42152c7e2b76af5e2aeb048103a (diff)
downloadgitea-93f03707a789a4d538c945c9838fa4ec4d3ef15c.tar.gz
gitea-93f03707a789a4d538c945c9838fa4ec4d3ef15c.zip
#2283 set text/plain for non-binary files in raw mode
Diffstat (limited to 'modules/base')
-rw-r--r--modules/base/tool.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go
index 9dcbb881d5..75f475fa4f 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -53,7 +53,11 @@ func ShortSha(sha1 string) string {
}
func DetectEncoding(content []byte) string {
- _, name, certain := charset.DetermineEncoding(content, setting.Repository.AnsiCharset)
+ _, name, certain := charset.DetermineEncoding(content, "")
+ if name != "utf-8" && len(setting.Repository.AnsiCharset) > 0 {
+ log.Debug("Using default AnsiCharset: %s", setting.Repository.AnsiCharset)
+ return setting.Repository.AnsiCharset
+ }
log.Debug("Detected encoding: %s (%v)", name, certain)
return name
}