emersion / go-imap

📥 An IMAP library for clients and servers
MIT License
2.09k stars 297 forks source link

v1: empty encoding in BodyStructure gets serialized as NIL #545

Closed ptrcnull closed 10 months ago

ptrcnull commented 1 year ago

i assume the encoding should never be specified as an empty string; per RFC 2045:

     encoding := "Content-Transfer-Encoding" ":" mechanism

     mechanism := "7bit" / "8bit" / "binary" /
                  "quoted-printable" / "base64" /
                  ietf-token / x-token

nonetheless, the library accepts this scenario and the resulting BODYSTRUCTURE list cannot be parsed back:

* 11319 FETCH (UID 31137 BODYSTRUCTURE ("text" "plain" () NIL NIL NIL 6002 79 NIL NIL NIL NIL) ENVELOPE ("Sun, 10 Sep 2023 02:00:00 +0000" "acme-update" ((NIL NIL "notify" "ptrc.gay")) ((NIL NIL "notify" "ptrc.gay")) ((NIL NIL "notify" "ptrc.gay")) ((NIL NIL "ptrc" "ptrc.gay")) NIL NIL NIL NIL) FLAGS (\Seen nonjunk \Recent))
in response-data: in body-type-1part: imapwire: expected string, got "N"
emersion commented 10 months ago

This seems like a v2 issue? At least, the error message comes from v2.