diff --git a/home/filter.go b/home/filter.go index 73c4d9a0..8bf902a2 100644 --- a/home/filter.go +++ b/home/filter.go @@ -370,11 +370,17 @@ func (filter *filter) update() (bool, error) { return false, nil } - if !isPrintableText(body[:4096]) { + var firstChunk []byte + if len(body) <= 4096 { + firstChunk = body + } else { + firstChunk = body[:4096] + } + if !isPrintableText(firstChunk) { return false, fmt.Errorf("Data contains non-printable characters") } - s := strings.ToLower(string(body[:4096])) + s := strings.ToLower(string(firstChunk)) if strings.Index(s, "= 0 || strings.Index(s, "= 0 { return false, fmt.Errorf("Data is HTML, not plain text")