fix(GODT-1804): Only promote content headers if non-empty

When attaching public key, we take the root mime part, create a new root,
and put the old root alongside an additional public key mime part.
But when moving the root, we would copy all content headers, even empty ones.
So we’d be left with Content-Disposition: "" which would fail to parse.
This commit is contained in:
James Houlahan
2023-02-03 11:47:04 +01:00
parent 8894a982f2
commit d82b71de89
6 changed files with 213 additions and 7 deletions

View File

@ -186,9 +186,17 @@ func (p *Part) isMultipartMixed() bool {
func getContentHeaders(header message.Header) message.Header {
var res message.Header
res.Set("Content-Type", header.Get("Content-Type"))
res.Set("Content-Disposition", header.Get("Content-Disposition"))
res.Set("Content-Transfer-Encoding", header.Get("Content-Transfer-Encoding"))
if contentType := header.Get("Content-Type"); contentType != "" {
res.Set("Content-Type", contentType)
}
if contentDisposition := header.Get("Content-Disposition"); contentDisposition != "" {
res.Set("Content-Disposition", contentDisposition)
}
if contentTransferEncoding := header.Get("Content-Transfer-Encoding"); contentTransferEncoding != "" {
res.Set("Content-Transfer-Encoding", contentTransferEncoding)
}
return res
}