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

for issue #272 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

View File

@ -645,7 +645,7 @@ var ErrParamEncoding = errors.New("bad header parameter encoding")
func (p *Part) DispositionFilename() (disposition string, filename string, err error) { func (p *Part) DispositionFilename() (disposition string, filename string, err error) {
h, err := p.Header() h, err := p.Header()
if err != nil { if err != nil {
return "", "", fmt.Errorf("parsing header: %v", err) return "", "", fmt.Errorf("parsing header: %w", err)
} }
var disp string var disp string
var params map[string]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 { return func(m store.Message) bool {
if !state.ensurePart(m, false) { if !state.ensurePart(m, true) {
return false return false
} }
types, err := attachmentTypes(log, m, state) types, err := attachmentTypes(log, m, state)
@ -1872,7 +1872,7 @@ func attachmentTypes(log mlog.Log, m store.Message, state *msgState) (map[Attach
continue continue
} }
_, filename, err := a.Part.DispositionFilename() _, 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) log.Debugx("parsing disposition/filename", err)
} else if err != nil { } else if err != nil {
return nil, fmt.Errorf("reading disposition/filename: %v", err) return nil, fmt.Errorf("reading disposition/filename: %v", err)