From 4ffa62f6ca1829666e595e7c43ffaeddb0c5bea5 Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Thu, 28 Jan 2021 14:53:08 +0100 Subject: [PATCH] fix: set contentID if present and not explicitly attachment --- pkg/message/parser.go | 12 +++++++++++- unreleased.md | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/message/parser.go b/pkg/message/parser.go index f84b6cdd..5a7a9cac 100644 --- a/pkg/message/parser.go +++ b/pkg/message/parser.go @@ -528,7 +528,17 @@ func parseAttachment(h message.Header) (*pmapi.Attachment, error) { // Only set ContentID if it should be inline; // API infers content disposition based on whether ContentID is present. - if disp, _, err := h.ContentDisposition(); err == nil && disp == "inline" { + // If Content-Disposition is present, we base our decision on that. + // Otherwise, if Content-Disposition is missing but there is a ContentID, set it. + // (This is necessary because some clients don't set Content-Disposition at all, + // so we need to rely on other information to deduce if it's inline or attachment.) + if h.Has("Content-Disposition") { + if disp, _, err := h.ContentDisposition(); err != nil { + return nil, err + } else if disp == "inline" { + att.ContentID = strings.Trim(h.Get("Content-Id"), " <>") + } + } else if h.Has("Content-Id") { att.ContentID = strings.Trim(h.Get("Content-Id"), " <>") } diff --git a/unreleased.md b/unreleased.md index 0deef91e..3d2a49cd 100644 --- a/unreleased.md +++ b/unreleased.md @@ -13,3 +13,4 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/) ### Fixed * GODT-787 GODT-978 Fix IE and Bridge importing to sent not showing up in inbox (setting up flags properly). * GODT-1006 Use correct macOS keychain name. +* GODT-1009 Set ContentID if present and not explicitly attachment.