diff options
author | Unknwon <u@gogs.io> | 2016-08-31 13:59:23 -0700 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-08-31 13:59:23 -0700 |
commit | dadd35b63647327bed02719f6cda5d25256fa49e (patch) | |
tree | a05aa8f90afc18542b6373cdf747c39df8e67c11 /modules/base | |
parent | c2afdf2192b9f0287968e29160e30a45a3ff1339 (diff) | |
download | gitea-dadd35b63647327bed02719f6cda5d25256fa49e.tar.gz gitea-dadd35b63647327bed02719f6cda5d25256fa49e.zip |
#3559 fix template error
Diffstat (limited to 'modules/base')
-rw-r--r-- | modules/base/tool.go | 4 |
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 } |