forked from Silverfish/proton-bridge
fix(GODT-3176): assume inline if content id is present.
This commit is contained in:
committed by
Jakub Cuth
parent
76d257af21
commit
773a230d14
@ -119,7 +119,7 @@ func parse(p *parser.Parser, allowInvalidAddressLists bool) (Message, error) {
|
||||
}
|
||||
|
||||
if err := patchInlineImages(p); err != nil {
|
||||
return Message{}, err
|
||||
return Message{}, errors.Wrap(err, "patching inline images failed")
|
||||
}
|
||||
|
||||
m, err := parseMessageHeader(p.Root().Header, allowInvalidAddressLists)
|
||||
@ -671,11 +671,10 @@ func patchInlineImages(p *parser.Parser) error {
|
||||
if rfc822.MIMEType(contentType) == rfc822.TextPlain {
|
||||
result[i] = &inlinePatchBodyOnly{part: curPart, contentTypeMap: contentTypeMap}
|
||||
} else if strings.HasPrefix(contentType, "image/") {
|
||||
disposition, _, err := curPart.ContentDisposition()
|
||||
disposition, err := getImageContentDisposition(curPart)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failted to get content disposition for child %v:%w", i, err)
|
||||
return fmt.Errorf("failed to get content disposition for child %v:%w", i, err)
|
||||
}
|
||||
|
||||
if disposition == "inline" && !curPart.HasContentID() {
|
||||
if rfc822.MIMEType(prevContentType) == rfc822.TextPlain {
|
||||
result[i-1] = &inlinePatchBodyWithInlineImage{
|
||||
@ -707,6 +706,23 @@ func patchInlineImages(p *parser.Parser) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func getImageContentDisposition(curPart *parser.Part) (string, error) {
|
||||
disposition, _, err := curPart.ContentDisposition()
|
||||
if err == nil {
|
||||
return disposition, nil
|
||||
}
|
||||
|
||||
if curPart.Header.Get("Content-Disposition") != "" {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if curPart.HasContentID() {
|
||||
return "inline", nil
|
||||
}
|
||||
|
||||
return "attachment", nil
|
||||
}
|
||||
|
||||
type inlinePatchJob interface {
|
||||
Patch()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user