- crash after filter update if its data is too small
This commit is contained in:
parent
309feeae9a
commit
319cc848bd
|
@ -370,11 +370,17 @@ func (filter *filter) update() (bool, error) {
|
||||||
return false, nil
|
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")
|
return false, fmt.Errorf("Data contains non-printable characters")
|
||||||
}
|
}
|
||||||
|
|
||||||
s := strings.ToLower(string(body[:4096]))
|
s := strings.ToLower(string(firstChunk))
|
||||||
if strings.Index(s, "<html") >= 0 ||
|
if strings.Index(s, "<html") >= 0 ||
|
||||||
strings.Index(s, "<!doctype") >= 0 {
|
strings.Index(s, "<!doctype") >= 0 {
|
||||||
return false, fmt.Errorf("Data is HTML, not plain text")
|
return false, fmt.Errorf("Data is HTML, not plain text")
|
||||||
|
|
Loading…
Reference in New Issue