From 4993ab1a767bea5645a65b5639cc00bb107fdfd3 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 31 Dec 2015 22:13:47 -0500 Subject: #2185 fall back to use custom chardet lib --- models/git_diff.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'models') diff --git a/models/git_diff.go b/models/git_diff.go index 1b2fb5f2b1..22075ef76b 100644 --- a/models/git_diff.go +++ b/models/git_diff.go @@ -246,8 +246,8 @@ func ParsePatch(maxlines int, reader io.Reader) (*Diff, error) { buf.WriteString("\n") } } - charsetLabel := base.DetectEncoding(buf.Bytes()) - if charsetLabel != "UTF-8" { + charsetLabel, err := base.DetectEncoding(buf.Bytes()) + if charsetLabel != "UTF-8" && err == nil { encoding, _ := charset.Lookup(charsetLabel) if encoding != nil { d := encoding.NewDecoder() -- cgit v1.2.3