summaryrefslogtreecommitdiffstats
path: root/modules/base
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-08-31 13:59:23 -0700
committerUnknwon <u@gogs.io>2016-08-31 13:59:23 -0700
commitdadd35b63647327bed02719f6cda5d25256fa49e (patch)
treea05aa8f90afc18542b6373cdf747c39df8e67c11 /modules/base
parentc2afdf2192b9f0287968e29160e30a45a3ff1339 (diff)
downloadgitea-dadd35b63647327bed02719f6cda5d25256fa49e.tar.gz
gitea-dadd35b63647327bed02719f6cda5d25256fa49e.zip
#3559 fix template error
Diffstat (limited to 'modules/base')
-rw-r--r--modules/base/tool.go4
1 files changed, 4 insertions, 0 deletions
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
}