Prechádzať zdrojové kódy

Fixed bug with building merge diff for files with different charset

Ivan Arkhipov 6 rokov pred
rodič
commit
cc27ef13c2
1 zmenil súbory, kde vykonal 4 pridanie a 0 odobranie
  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