Skip to content

Commit

Permalink
fixed issue when uploading same file under different name
Browse files Browse the repository at this point in the history
  • Loading branch information
Carsten Seeger committed Aug 21, 2020
1 parent 7325395 commit e1dbb65
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/mailparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,8 @@ func (m Mail2Most) parseAttachment(body []byte, header string) (Attachment, erro

sum := sha256.Sum256(body)
if _, ok := seenAttachments[sum]; ok {
// throwing an error here is a bit strange it would be better to return the existing attachment
// btw this could be exploited by creating a hash colision :D
return Attachment{}, errors.New("attachment already exists")
return Attachment{Filename: seenAttachments[sum], Content: body}, nil
}

seenAttachments[sum] = filename
Expand Down

0 comments on commit e1dbb65

Please sign in to comment.