Pārlūkot izejas kodu

Fixed bug with building merge diff for files with different charset

Ivan Arkhipov 6 gadi atpakaļ
vecāks
revīzija
cc27ef13c2
1 mainītis faili ar 4 papildinājumiem un 0 dzēšanām
  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