imap: fix FETCH BODY[N]

This commit is contained in:
Simon Ser 2019-07-24 22:27:35 +03:00
parent 6dfa094227
commit 161569708a
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
1 changed files with 10 additions and 1 deletions

View File

@ -348,10 +348,19 @@ func (mbox *mailbox) fetchBodySection(msg *protonmail.Message, section *imap.Bod
return nil, err return nil, err
} }
if section.Specifier == imap.TextSpecifier { switch section.Specifier {
case imap.TextSpecifier:
// The header hasn't been requested. Discard it.
b.Reset() b.Reset()
case imap.EntireSpecifier:
if len(section.Path) > 0 {
// When selecting a specific part by index, IMAP servers
// return only the text, not the associated MIME header.
b.Reset()
}
} }
// Write the body, if requested
switch section.Specifier { switch section.Specifier {
case imap.EntireSpecifier, imap.TextSpecifier: case imap.EntireSpecifier, imap.TextSpecifier:
r, err := getBody() r, err := getBody()