1
1
Fork 0
mirror of https://github.com/mjl-/mox.git synced 2025-04-21 21:40:01 +03:00

webmail: fix nil pointer dereference when searching for attachment types, eg "a:spreadsheet"

for issue  by mattfbacon
This commit is contained in:
Mechiel Lukkien 2025-01-23 11:03:08 +01:00
parent 008de1cafb
commit 0203dfa9d9
No known key found for this signature in database
2 changed files with 3 additions and 3 deletions
message
webmail

View file

@ -645,7 +645,7 @@ var ErrParamEncoding = errors.New("bad header parameter encoding")
func (p *Part) DispositionFilename() (disposition string, filename string, err error) {
h, err := p.Header()
if err != nil {
return "", "", fmt.Errorf("parsing header: %v", err)
return "", "", fmt.Errorf("parsing header: %w", err)
}
var disp string
var params map[string]string

View file

@ -1803,7 +1803,7 @@ func (q Query) attachmentFilterFn(log mlog.Log, acc *store.Account, state *msgSt
}
return func(m store.Message) bool {
if !state.ensurePart(m, false) {
if !state.ensurePart(m, true) {
return false
}
types, err := attachmentTypes(log, m, state)
@ -1872,7 +1872,7 @@ func attachmentTypes(log mlog.Log, m store.Message, state *msgState) (map[Attach
continue
}
_, filename, err := a.Part.DispositionFilename()
if err != nil && errors.Is(err, message.ErrParamEncoding) {
if err != nil && (errors.Is(err, message.ErrParamEncoding) || errors.Is(err, message.ErrHeader)) {
log.Debugx("parsing disposition/filename", err)
} else if err != nil {
return nil, fmt.Errorf("reading disposition/filename: %v", err)