Simplify references parsing

This commit is contained in:
Pavel Škoda
2020-05-11 10:39:54 +02:00
committed by Pavel Škoda
parent 4a8d07d54e
commit 2639f7333e
3 changed files with 5 additions and 5 deletions

View File

@ -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>")]

View File

@ -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

View File

@ -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: <base64hashOfSomeMessage@protonmail.internalID>
References: <base64hashOfSomeConversation@protonmail.internalID> <base64hashOfSomeConversation@protonmail.conversationID>
<html><body>This is body of <b>HTML mail</b> without attachment<body></html>