Skip to content

Commit f22ae1e

Browse files
committed
🔥 Drop deprecated BodyType structs
These were always a bit buggy, and they've been marked as deprecated_constant since v0.4, so hopefully there won't too much impact on anyone.
1 parent 3b3f8ae commit f22ae1e

File tree

2 files changed

+0
-91
lines changed

2 files changed

+0
-91
lines changed

lib/net/imap/response_data.rb

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,77 +1040,6 @@ def media_subtype
10401040
end
10411041
end
10421042

1043-
# BodyTypeAttachment is not used and will be removed in an upcoming release.
1044-
#
1045-
# === Bug Analysis
1046-
#
1047-
# \IMAP body structures are parenthesized lists and assign their fields
1048-
# positionally, so missing fields change the interpretation of all
1049-
# following fields. Additionally, different body types have a different
1050-
# number of required fields, followed by optional "extension" fields.
1051-
#
1052-
# BodyTypeAttachment was previously returned when a "message/rfc822" part,
1053-
# which should be sent as <tt>body-type-msg</tt> with ten required fields,
1054-
# was actually sent as a <tt>body-type-basic</tt> with _seven_ required
1055-
# fields.
1056-
#
1057-
# basic => type, subtype, param, id, desc, enc, octets, md5=nil, dsp=nil, lang=nil, loc=nil, *ext
1058-
# msg => type, subtype, param, id, desc, enc, octets, envelope, body, lines, md5=nil, ...
1059-
#
1060-
# Normally, +envelope+ and +md5+ are incompatible, but Net::IMAP leniently
1061-
# allowed buggy servers to send +NIL+ for +envelope+. As a result, when a
1062-
# server sent a <tt>message/rfc822</tt> part with +NIL+ for +md5+ and a
1063-
# non-<tt>NIL</tt> +dsp+, Net::IMAP misinterpreted the
1064-
# <tt>Content-Disposition</tt> as if it were a strange body type. In all
1065-
# reported cases, the <tt>Content-Disposition</tt> was "attachment", so
1066-
# BodyTypeAttachment was created as the workaround.
1067-
#
1068-
# === Current behavior
1069-
#
1070-
# When interpreted strictly, +envelope+ and +md5+ are incompatible. So the
1071-
# current parsing algorithm peeks ahead after it has received the seventh
1072-
# body field. If the next token is not the start of an +envelope+, we assume
1073-
# the server has incorrectly sent us a <tt>body-type-basic</tt> and return
1074-
# BodyTypeBasic. As a result, what was previously BodyTypeMessage#body =>
1075-
# BodyTypeAttachment is now BodyTypeBasic#disposition => ContentDisposition.
1076-
#
1077-
class BodyTypeAttachment < Struct.new(:dsp_type, :_unused_, :param)
1078-
# *invalid for BodyTypeAttachment*
1079-
def media_type
1080-
warn(<<~WARN, uplevel: 1)
1081-
BodyTypeAttachment#media_type is obsolete. Use dsp_type instead.
1082-
WARN
1083-
dsp_type
1084-
end
1085-
1086-
# *invalid for BodyTypeAttachment*
1087-
def subtype
1088-
warn("BodyTypeAttachment#subtype is obsolete.\n", uplevel: 1)
1089-
nil
1090-
end
1091-
1092-
##
1093-
# method: dsp_type
1094-
# :call-seq: dsp_type -> string
1095-
#
1096-
# Returns the content disposition type, as defined by
1097-
# [DISPOSITION[https://tools.ietf.org/html/rfc2183]].
1098-
1099-
##
1100-
# method: param
1101-
# :call-seq: param -> hash
1102-
#
1103-
# Returns a hash representing parameters of the Content-Disposition
1104-
# field, as defined by [DISPOSITION[https://tools.ietf.org/html/rfc2183]].
1105-
1106-
##
1107-
def multipart?
1108-
return false
1109-
end
1110-
end
1111-
1112-
deprecate_constant :BodyTypeAttachment
1113-
11141043
# Net::IMAP::BodyTypeMultipart represents body structures of messages and
11151044
# message parts, when <tt>Content-Type</tt> is <tt>multipart/*</tt>.
11161045
class BodyTypeMultipart < Struct.new(:media_type, :subtype,
@@ -1187,24 +1116,5 @@ def media_subtype
11871116
end
11881117
end
11891118

1190-
# === Obsolete
1191-
# BodyTypeExtension is not used and will be removed in an upcoming release.
1192-
#
1193-
# >>>
1194-
# BodyTypeExtension was (incorrectly) used for <tt>message/*</tt> parts
1195-
# (besides <tt>message/rfc822</tt>, which correctly uses BodyTypeMessage).
1196-
#
1197-
# Net::IMAP now (correctly) parses all message types (other than
1198-
# <tt>message/rfc822</tt> or <tt>message/global</tt>) as BodyTypeBasic.
1199-
class BodyTypeExtension < Struct.new(:media_type, :subtype,
1200-
:params, :content_id,
1201-
:description, :encoding, :size)
1202-
def multipart?
1203-
return false
1204-
end
1205-
end
1206-
1207-
deprecate_constant :BodyTypeExtension
1208-
12091119
end
12101120
end

test/net/imap/test_regexps.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class IMAPRegexpsTest < Test::Unit::TestCase
2626
Net::IMAP,
2727
exclude_map: {
2828
Net::IMAP => %i[
29-
BodyTypeAttachment BodyTypeExtension
3029
PlainAuthenticator
3130
XOauth2Authenticator
3231
], # deprecated

0 commit comments

Comments
 (0)