summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Vissoultchev <wqweto@gmail.com>2015-07-29 17:58:03 +0300
committerVladimir Vissoultchev <wqweto@gmail.com>2015-07-29 17:58:03 +0300
commit2cc050e21ed35d95d824cc22d129fc22ee1318a4 (patch)
tree6a6a17749a305325d8226f8b2950cfd0404860ef
parent4917d29c121af221c3768871efabc5f99b88c4b8 (diff)
downloadgitea-2cc050e21ed35d95d824cc22d129fc22ee1318a4.tar.gz
gitea-2cc050e21ed35d95d824cc22d129fc22ee1318a4.zip
Fix UTF-8 in upper-case, use ansi charset for all non UTF-8 encodings
-rw-r--r--modules/base/template.go4
-rw-r--r--modules/setting/setting.go2
-rw-r--r--routers/repo/download.go2
3 files changed, 4 insertions, 4 deletions
diff --git a/modules/base/template.go b/modules/base/template.go
index f0a2e0329c..2a81a34d26 100644
--- a/modules/base/template.go
+++ b/modules/base/template.go
@@ -55,7 +55,7 @@ func ShortSha(sha1 string) string {
func DetectEncoding(content []byte) (string, error) {
detector := chardet.NewTextDetector()
result, err := detector.DetectBest(content)
- if result.Charset == "ISO-8859-1" {
+ if result.Charset != "UTF-8" && len(setting.AnsiCharset) > 0 {
return setting.AnsiCharset, err
}
return result.Charset, err
@@ -67,7 +67,7 @@ func ToUtf8WithErr(content []byte) (error, string) {
return err, ""
}
- if charsetLabel == "utf8" {
+ if charsetLabel == "UTF-8" {
return nil, string(content)
}
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 896e60ad13..f826a3a41a 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -313,7 +313,7 @@ func NewConfigContext() {
RepoRootPath = path.Clean(RepoRootPath)
}
ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
- AnsiCharset = sec.Key("ANSI_CHARSET").MustString("ISO-8859-1")
+ AnsiCharset = sec.Key("ANSI_CHARSET").MustString("")
// UI settings.
IssuePagingNum = Cfg.Section("ui").Key("ISSUE_PAGING_NUM").MustInt(10)
diff --git a/routers/repo/download.go b/routers/repo/download.go
index 8e9efba31b..c71f8d293e 100644
--- a/routers/repo/download.go
+++ b/routers/repo/download.go
@@ -28,7 +28,7 @@ func ServeBlob(ctx *middleware.Context, blob *git.Blob) error {
_, isTextFile := base.IsTextFile(buf)
if isTextFile {
charset, _ := base.DetectEncoding(buf)
- if charset != "utf-8" {
+ if charset != "UTF-8" {
ctx.Resp.Header().Set("Content-Type", "text/plain; charset="+charset)
}
} else {