class Net::IMAP::BodyTypeAttachment
BodyTypeAttachment
is not used and will be removed in an upcoming release.
Bug Analysis¶ ↑
IMAP body structures are parenthesized lists and assign their fields positionally, so missing fields change the intepretation of all following fields. Additionally, different body types have a different number of required fields, followed by optional “extension” fields.
BodyTypeAttachment
was previously returned when a “message/rfc822” part, which should be sent as body-type-msg
with ten required fields, was actually sent as a body-type-basic
with seven required fields.
basic => type, subtype, param, id, desc, enc, octets, md5=nil, dsp=nil, lang=nil, loc=nil, *ext msg => type, subtype, param, id, desc, enc, octets, envelope, body, lines, md5=nil, ...
Normally, envelope
and md5
are incompatible, but Net::IMAP
leniently allowed buggy servers to send NIL
for envelope
. As a result, when a server sent a message/rfc822
part with NIL
for md5
and a non-NIL
dsp
, Net::IMAP
mis-interpreted the Content-Disposition
as if it were a strange body type. In all reported cases, the Content-Disposition
was “attachment”, so BodyTypeAttachment
was created as the workaround.
Current behavior¶ ↑
When interpreted strictly, envelope
and md5
are incompatible. So the current parsing algorithm peeks ahead after it has recieved the seventh body field. If the next token is not the start of an envelope
, we assume the server has incorrectly sent us a body-type-basic
and return BodyTypeBasic
. As a result, what was previously BodyTypeMessage#body
=> BodyTypeAttachment
is now BodyTypeBasic#disposition
=> ContentDisposition
.
Public Instance Methods
Returns the content disposition type, as defined by [DISPOSITION].
# File net-imap-0.4.9.1/lib/net/imap/response_data.rb, line 1093
# File net-imap-0.4.9.1/lib/net/imap/response_data.rb, line 1079 def media_type warn(<<~WARN, uplevel: 1) BodyTypeAttachment#media_type is obsolete. Use dsp_type instead. WARN dsp_type end
# File net-imap-0.4.9.1/lib/net/imap/response_data.rb, line 1107 def multipart? return false end
Returns a hash representing parameters of the Content-Disposition field, as defined by [DISPOSITION].
# File net-imap-0.4.9.1/lib/net/imap/response_data.rb, line 1100
*invalid for BodyTypeAttachment*
# File net-imap-0.4.9.1/lib/net/imap/response_data.rb, line 1087 def subtype warn("BodyTypeAttachment#subtype is obsolete.\n", uplevel: 1) nil end