mirror of
https://github.com/mjl-/mox.git
synced 2025-07-14 22:54:37 +03:00
add strict mode when parsing messages, typically enabled for incoming special-use messages like tls/dmarc reports, subjectpass emails
and pass a logger to the message parser, so problems with message parsing get the cid logged.
This commit is contained in:
@ -501,7 +501,7 @@ func (f *Filter) ClassifyMessagePath(ctx context.Context, path string) (probabil
|
||||
}
|
||||
|
||||
func (f *Filter) ClassifyMessageReader(ctx context.Context, mf io.ReaderAt, size int64) (probability float64, words map[string]struct{}, nham, nspam int, rerr error) {
|
||||
m, err := message.EnsurePart(mf, size)
|
||||
m, err := message.EnsurePart(f.log, false, mf, size)
|
||||
if err != nil && errors.Is(err, message.ErrBadContentType) {
|
||||
// Invalid content-type header is a sure sign of spam.
|
||||
//f.log.Infox("parsing content", err)
|
||||
@ -567,7 +567,7 @@ func (f *Filter) Train(ctx context.Context, ham bool, words map[string]struct{})
|
||||
}
|
||||
|
||||
func (f *Filter) TrainMessage(ctx context.Context, r io.ReaderAt, size int64, ham bool) error {
|
||||
p, _ := message.EnsurePart(r, size)
|
||||
p, _ := message.EnsurePart(f.log, false, r, size)
|
||||
words, err := f.ParseMessage(p)
|
||||
if err != nil {
|
||||
return fmt.Errorf("parsing mail contents: %v", err)
|
||||
@ -576,7 +576,7 @@ func (f *Filter) TrainMessage(ctx context.Context, r io.ReaderAt, size int64, ha
|
||||
}
|
||||
|
||||
func (f *Filter) UntrainMessage(ctx context.Context, r io.ReaderAt, size int64, ham bool) error {
|
||||
p, _ := message.EnsurePart(r, size)
|
||||
p, _ := message.EnsurePart(f.log, false, r, size)
|
||||
words, err := f.ParseMessage(p)
|
||||
if err != nil {
|
||||
return fmt.Errorf("parsing mail contents: %v", err)
|
||||
|
@ -31,7 +31,7 @@ func (f *Filter) tokenizeMail(path string) (bool, map[string]struct{}, error) {
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
p, _ := message.EnsurePart(mf, fi.Size())
|
||||
p, _ := message.EnsurePart(f.log, false, mf, fi.Size())
|
||||
words, err := f.ParseMessage(p)
|
||||
return true, words, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user