From dadd35b63647327bed02719f6cda5d25256fa49e Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 31 Aug 2016 13:59:23 -0700 Subject: #3559 fix template error --- modules/base/tool.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules/base/tool.go') diff --git a/modules/base/tool.go b/modules/base/tool.go index e321d2b868..52d1e178db 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -518,7 +518,11 @@ func IsLetter(ch rune) bool { return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_' || ch >= 0x80 && unicode.IsLetter(ch) } +// IsTextFile returns true if file content format is plain text or empty. func IsTextFile(data []byte) bool { + if len(data) == 0 { + return true + } return strings.Index(http.DetectContentType(data), "text/") != -1 } -- cgit v1.2.3