Skip to content

Commit

Permalink
webmail: fix nil pointer dereference when searching for attachment ty…
Browse files Browse the repository at this point in the history
…pes, eg "a:spreadsheet"

for issue #272 by mattfbacon
  • Loading branch information
mjl- committed Jan 23, 2025
1 parent 008de1c commit 0203dfa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion message/part.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions webmail/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0203dfa

Please sign in to comment.