Skip to content

Commit

Permalink
🗑️ Deprecate Net::IMAP::MessageSet
Browse files Browse the repository at this point in the history
  • Loading branch information
nevans committed Sep 13, 2024
1 parent 9ee199f commit 374100b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
10 changes: 10 additions & 0 deletions lib/net/imap/command_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def initialize(data)
end
end

# *DEPRECATED*. Replaced by SequenceSet.
class MessageSet # :nodoc:
def send_data(imap, tag)
imap.__send__(:put_string, format_internal(@data))
Expand All @@ -192,6 +193,15 @@ def validate

def initialize(data)
@data = data
warn "DEPRECATED: #{MessageSet} should be replaced with #{SequenceSet}."
begin
# to ensure the input works with SequenceSet, too
SequenceSet.new(data)
rescue
warn "MessageSet input is incompatible with SequenceSet: [%s] %s" % [
$!.class, $!.message
]
end
end

def format_internal(data)
Expand Down
23 changes: 13 additions & 10 deletions test/net/imap/test_imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -626,17 +626,20 @@ def test_send_invalid_number
imap.__send__(:send_command, "TEST", 2**32)
end
# MessageSet numbers may be non-zero uint32
assert_raise(Net::IMAP::DataFormatError) do
imap.__send__(:send_command, "TEST", Net::IMAP::MessageSet.new(-1))
end
assert_raise(Net::IMAP::DataFormatError) do
imap.__send__(:send_command, "TEST", Net::IMAP::MessageSet.new(0))
end
imap.__send__(:send_command, "TEST", Net::IMAP::MessageSet.new(1))
imap.__send__(:send_command, "TEST", Net::IMAP::MessageSet.new(2**32 - 1))
assert_raise(Net::IMAP::DataFormatError) do
imap.__send__(:send_command, "TEST", Net::IMAP::MessageSet.new(2**32))
stderr = EnvUtil.verbose_warning do
assert_raise(Net::IMAP::DataFormatError) do
imap.__send__(:send_command, "TEST", Net::IMAP::MessageSet.new(-1))
end
assert_raise(Net::IMAP::DataFormatError) do
imap.__send__(:send_command, "TEST", Net::IMAP::MessageSet.new(0))
end
imap.__send__(:send_command, "TEST", Net::IMAP::MessageSet.new(1))
imap.__send__(:send_command, "TEST", Net::IMAP::MessageSet.new(2**32 - 1))
assert_raise(Net::IMAP::DataFormatError) do
imap.__send__(:send_command, "TEST", Net::IMAP::MessageSet.new(2**32))
end
end
assert_match(/DEPRECATED:.+MessageSet.+replace.+with.+SequenceSet/, stderr)
# SequenceSet numbers may be non-zero uint3, and -1 is translated to *
imap.__send__(:send_command, "TEST", Net::IMAP::SequenceSet.new(-1))
assert_raise(Net::IMAP::DataFormatError) do
Expand Down

0 comments on commit 374100b

Please sign in to comment.