瀏覽代碼

Fixed bug with building merge diff for files with different charset

Ivan Arkhipov 6 年之前
父節點
當前提交
cc27ef13c2
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      pkg/tool/tool.go

+ 4 - 0
pkg/tool/tool.go

@@ -62,6 +62,10 @@ func DetectEncoding(content []byte) (string, error) {
 	}
 
 	result, err := chardet.NewTextDetector().DetectBest(content)
+	if result == nil || err != nil {
+		return "UTF-8", err
+	}
+
 	if result.Charset != "UTF-8" && len(setting.Repository.AnsiCharset) > 0 {
 		log.Trace("Using default AnsiCharset: %s", setting.Repository.AnsiCharset)
 		return setting.Repository.AnsiCharset, err