fix: panic when no multipart/alternative children

This commit is contained in:
James Houlahan
2021-01-13 16:42:10 +01:00
parent 2f149eb545
commit 014c8af560
3 changed files with 10 additions and 3 deletions

View File

@ -1,4 +1,4 @@
// Copyright (c) 2020 Proton Technologies AG
// Copyright (c) 2021 Proton Technologies AG
//
// This file is part of ProtonMail Bridge.
//

View File

@ -329,10 +329,14 @@ func bestChoice(childParts []parser.Parts, preferredContentType string) parser.P
}
}
// Otherwise, choose the last one.
// Otherwise, choose the last one, if it exists.
if len(childParts) > 0 {
return childParts[len(childParts)-1]
}
return parser.Parts{}
}
func allPartsHaveContentType(parts parser.Parts, contentType string) bool {
if len(parts) == 0 {
return false

View File

@ -9,3 +9,6 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/)
### Removed
### Changed
### Fixed
* GODT-979 Fix panic when trying to parse a multipart/alternative section that has no child sections.