diff --git a/internal/imap/mailbox_message.go b/internal/imap/mailbox_message.go index 0151183d..e1d0e19c 100644 --- a/internal/imap/mailbox_message.go +++ b/internal/imap/mailbox_message.go @@ -148,7 +148,7 @@ func (im *imapMailbox) CreateMessage(flags []string, date time.Time, body imap.L if len(referenceList) > 0 { lastReference := referenceList[len(referenceList)-1] // In case we are using a mail client which corrupts headers, try "References" too. - re := regexp.MustCompile("<[a-zA-Z0-9-_=]*@protonmail.internalid>") + re := regexp.MustCompile(`(?U)<.*@protonmail.internalid>`) match := re.FindString(lastReference) if match != "" { internalID = match[1 : len(match)-len("@protonmail.internalid>")] diff --git a/internal/smtp/user.go b/internal/smtp/user.go index 9507dcb3..b2064cd8 100644 --- a/internal/smtp/user.go +++ b/internal/smtp/user.go @@ -373,9 +373,9 @@ func (su *smtpUser) handleReferencesHeader(m *pmapi.Message) (draftID, parentID if !strings.Contains(reference, "@protonmail.internalid") { newReferences = append(newReferences, reference) } else { // internalid is the parentID. - idMatch := regexp.MustCompile("[a-zA-Z0-9-_=]*@protonmail.internalid").FindString(reference) + idMatch := regexp.MustCompile(`(?U)<.*@protonmail.internalid>`).FindString(reference) if idMatch != "" { - lastID := idMatch[0 : len(idMatch)-len("@protonmail.internalid")] + lastID := idMatch[1 : len(idMatch)-len("@protonmail.internalid>")] filter := &pmapi.MessagesFilter{ID: []string{lastID}} if su.addressID != "" { filter.AddressID = su.addressID diff --git a/test/features/smtp/send/html.feature b/test/features/smtp/send/html.feature index 81f1cf13..2db6eb46 100644 --- a/test/features/smtp/send/html.feature +++ b/test/features/smtp/send/html.feature @@ -12,8 +12,8 @@ Feature: SMTP sending of HTML messages Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 - In-Reply-To: base64hashOfSomeMessage@protonmail.internalID - References: base64hashOfSomeConversation@protonmail.internalID base64hashOfSomeConversation@protonmail.conversationID + In-Reply-To: + References: This is body of HTML mail without attachment