Fix multipart header parsing in eml.go

The commit modifies the parseMultiPartHeader function to handle optional fields accurately. The delimiter was changed from "; " to ";" and whitespace is being trimmed from the start of optional fields to ensure correct splitting and mapping.
This commit is contained in:
Winni Neessen 2024-06-25 10:59:04 +02:00
parent faab5323fd
commit 8b1208949f
Signed by: wneessen
GPG key ID: 385AC9889632126E

5
eml.go
View file

@ -369,10 +369,11 @@ func handleEMLMultiPartBase64Encoding(multiPartData []byte, part *Part) error {
// separate map
func parseMultiPartHeader(multiPartHeader string) (header string, optional map[string]string) {
optional = make(map[string]string)
headerSplit := strings.SplitN(multiPartHeader, "; ", 2)
headerSplit := strings.SplitN(multiPartHeader, ";", 2)
header = headerSplit[0]
if len(headerSplit) == 2 {
optSplit := strings.SplitN(headerSplit[1], "=", 2)
optString := strings.TrimLeft(headerSplit[1], " ")
optSplit := strings.SplitN(optString, "=", 2)
if len(optSplit) == 2 {
optional[optSplit[0]] = optSplit[1]
}