Skip to content

Commit e1e2baf

Browse files
committed
💥🔥 Remove deprecated UIDPlusData class
1 parent 1b61019 commit e1e2baf

File tree

6 files changed

+9
-222
lines changed

6 files changed

+9
-222
lines changed

lib/net/imap.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,7 +2020,7 @@ def status(mailbox, attr)
20202020
#
20212021
# If +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] is
20222022
# supported and the destination supports persistent UIDs, the server's
2023-
# response should include an +APPENDUID+ response code with UIDPlusData.
2023+
# response should include an +APPENDUID+ response code with AppendUIDData.
20242024
# This will report the UIDVALIDITY of the destination mailbox and the
20252025
# assigned UID of the appended message.
20262026
#
@@ -2777,7 +2777,7 @@ def uid_store(set, attr, flags, unchangedsince: nil)
27772777
#
27782778
# If +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] is
27792779
# supported, the server's response should include a +COPYUID+ response code
2780-
# with UIDPlusData. This will report the UIDVALIDITY of the destination
2780+
# with CopyUIDData. This will report the UIDVALIDITY of the destination
27812781
# mailbox, the UID set of the source messages, and the assigned UID set of
27822782
# the moved messages.
27832783
#
@@ -2818,7 +2818,7 @@ def uid_copy(set, mailbox)
28182818
#
28192819
# If +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] is
28202820
# supported, the server's response should include a +COPYUID+ response code
2821-
# with UIDPlusData. This will report the UIDVALIDITY of the destination
2821+
# with CopyUIDData. This will report the UIDVALIDITY of the destination
28222822
# mailbox, the UID set of the source messages, and the assigned UID set of
28232823
# the moved messages.
28242824
#

lib/net/imap/response_data.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ class IMAP < Protocol
66
autoload :FetchData, "#{__dir__}/fetch_data"
77
autoload :UIDFetchData, "#{__dir__}/fetch_data"
88
autoload :SearchResult, "#{__dir__}/search_result"
9-
autoload :UIDPlusData, "#{__dir__}/uidplus_data"
109
autoload :AppendUIDData, "#{__dir__}/uidplus_data"
1110
autoload :CopyUIDData, "#{__dir__}/uidplus_data"
1211
autoload :VanishedData, "#{__dir__}/vanished_data"
@@ -260,8 +259,8 @@ class ResponseText < Struct.new(:code, :text)
260259
#
261260
# === +UIDPLUS+ extension
262261
# See {[RFC4315 §3]}[https://www.rfc-editor.org/rfc/rfc4315#section-3].
263-
# * +APPENDUID+, #data is UIDPlusData. See IMAP#append.
264-
# * +COPYUID+, #data is UIDPlusData. See IMAP#copy.
262+
# * +APPENDUID+, #data is AppendUIDData. See IMAP#append.
263+
# * +COPYUID+, #data is CopyUIDData. See IMAP#copy.
265264
# * +UIDNOTSTICKY+, #data is +nil+. See IMAP#select.
266265
#
267266
# === +SEARCHRES+ extension

lib/net/imap/response_parser.rb

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,23 +2017,8 @@ def resp_code_copy__data
20172017
CopyUID(validity, src_uids, dst_uids)
20182018
end
20192019

2020-
def AppendUID(...) DeprecatedUIDPlus(...) || AppendUIDData.new(...) end
2021-
def CopyUID(...) DeprecatedUIDPlus(...) || CopyUIDData.new(...) end
2022-
2023-
# TODO: remove this code in the v0.6.0 release
2024-
def DeprecatedUIDPlus(validity, src_uids = nil, dst_uids)
2025-
return unless config.parser_use_deprecated_uidplus_data
2026-
compact_uid_sets = [src_uids, dst_uids].compact
2027-
count = compact_uid_sets.map { _1.count_with_duplicates }.max
2028-
max = config.parser_max_deprecated_uidplus_data_size
2029-
if count <= max
2030-
src_uids &&= src_uids.each_ordered_number.to_a
2031-
dst_uids = dst_uids.each_ordered_number.to_a
2032-
UIDPlusData.new(validity, src_uids, dst_uids)
2033-
elsif config.parser_use_deprecated_uidplus_data != :up_to_max_size
2034-
parse_error("uid-set is too large: %d > %d", count, max)
2035-
end
2036-
end
2020+
def AppendUID(...) AppendUIDData.new(...) end
2021+
def CopyUID(...) CopyUIDData.new(...) end
20372022

20382023
ADDRESS_REGEXP = /\G
20392024
\( (?: NIL | #{Patterns::QUOTED_rev2} ) # 1: NAME

lib/net/imap/uidplus_data.rb

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -3,69 +3,8 @@
33
module Net
44
class IMAP < Protocol
55

6-
# *NOTE:* <em>UIDPlusData is deprecated and will be removed in the +0.6.0+
7-
# release.</em> To use AppendUIDData and CopyUIDData before +0.6.0+, set
8-
# Config#parser_use_deprecated_uidplus_data to +false+.
9-
#
10-
# UIDPlusData represents the ResponseCode#data that accompanies the
11-
# +APPENDUID+ and +COPYUID+ {response codes}[rdoc-ref:ResponseCode].
12-
#
13-
# A server that supports +UIDPLUS+ should send UIDPlusData in response to
14-
# the append[rdoc-ref:Net::IMAP#append], copy[rdoc-ref:Net::IMAP#copy],
15-
# move[rdoc-ref:Net::IMAP#move], {uid copy}[rdoc-ref:Net::IMAP#uid_copy],
16-
# and {uid move}[rdoc-ref:Net::IMAP#uid_move] commands---unless the
17-
# destination mailbox reports +UIDNOTSTICKY+.
18-
#
19-
# Note that append[rdoc-ref:Net::IMAP#append], copy[rdoc-ref:Net::IMAP#copy]
20-
# and {uid_copy}[rdoc-ref:Net::IMAP#uid_copy] return UIDPlusData in their
21-
# TaggedResponse. But move[rdoc-ref:Net::IMAP#copy] and
22-
# {uid_move}[rdoc-ref:Net::IMAP#uid_move] _should_ send UIDPlusData in an
23-
# UntaggedResponse response before sending their TaggedResponse. However
24-
# some servers do send UIDPlusData in the TaggedResponse for +MOVE+
25-
# commands---this complies with the older +UIDPLUS+ specification but is
26-
# discouraged by the +MOVE+ extension and disallowed by +IMAP4rev2+.
27-
#
28-
# == Required capability
29-
# Requires either +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315]]
30-
# or +IMAP4rev2+ capability.
31-
#
32-
class UIDPlusData < Struct.new(:uidvalidity, :source_uids, :assigned_uids)
33-
##
34-
# method: uidvalidity
35-
# :call-seq: uidvalidity -> nonzero uint32
36-
#
37-
# The UIDVALIDITY of the destination mailbox.
38-
39-
##
40-
# method: source_uids
41-
# :call-seq: source_uids -> nil or an array of nonzero uint32
42-
#
43-
# The UIDs of the copied or moved messages.
44-
#
45-
# Note:: Returns +nil+ for Net::IMAP#append.
46-
47-
##
48-
# method: assigned_uids
49-
# :call-seq: assigned_uids -> an array of nonzero uint32
50-
#
51-
# The newly assigned UIDs of the copied, moved, or appended messages.
52-
#
53-
# Note:: This always returns an array, even when it contains only one UID.
54-
55-
##
56-
# :call-seq: uid_mapping -> nil or a hash
57-
#
58-
# Returns a hash mapping each source UID to the newly assigned destination
59-
# UID.
60-
#
61-
# Note:: Returns +nil+ for Net::IMAP#append.
62-
def uid_mapping
63-
source_uids&.zip(assigned_uids)&.to_h
64-
end
65-
end
66-
676
# >>>
68-
# *NOTE:* <em>AppendUIDData will replace UIDPlusData for +APPENDUID+ in the
7+
# *NOTE:* <em>AppendUIDData replaced UIDPlusData for +APPENDUID+ in the
698
# +0.6.0+ release.</em> To use AppendUIDData before +0.6.0+, set
709
# Config#parser_use_deprecated_uidplus_data to +false+.
7110
#
@@ -109,7 +48,7 @@ def size
10948
end
11049

11150
# >>>
112-
# *NOTE:* <em>CopyUIDData will replace UIDPlusData for +COPYUID+ in the
51+
# *NOTE:* <em>CopyUIDData replaced UIDPlusData for +COPYUID+ in the
11352
# +0.6.0+ release.</em> To use CopyUIDData before +0.6.0+, set
11453
# Config#parser_use_deprecated_uidplus_data to +false+.
11554
#

test/net/imap/test_response_parser.rb

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -201,51 +201,6 @@ def test_fetch_binary_and_binary_size
201201
end
202202
end
203203

204-
test "APPENDUID with parser_use_deprecated_uidplus_data = true" do
205-
parser = Net::IMAP::ResponseParser.new(config: {
206-
parser_use_deprecated_uidplus_data: true,
207-
parser_max_deprecated_uidplus_data_size: 10_000,
208-
})
209-
assert_raise_with_message Net::IMAP::ResponseParseError, /uid-set is too large/ do
210-
parser.parse(
211-
"A004 OK [APPENDUID 1 10000:20000,1] Done\r\n"
212-
)
213-
end
214-
response = parser.parse("A004 OK [APPENDUID 1 100:200] Done\r\n")
215-
uidplus = response.data.code.data
216-
assert_equal 101, uidplus.assigned_uids.size
217-
parser.config.parser_max_deprecated_uidplus_data_size = 100
218-
assert_raise_with_message Net::IMAP::ResponseParseError, /uid-set is too large/ do
219-
parser.parse(
220-
"A004 OK [APPENDUID 1 100:200] Done\r\n"
221-
)
222-
end
223-
response = parser.parse("A004 OK [APPENDUID 1 101:200] Done\r\n")
224-
uidplus = response.data.code.data
225-
assert_instance_of Net::IMAP::UIDPlusData, uidplus
226-
assert_equal 100, uidplus.assigned_uids.size
227-
end
228-
229-
test "APPENDUID with parser_use_deprecated_uidplus_data = :up_to_max_size" do
230-
parser = Net::IMAP::ResponseParser.new(config: {
231-
parser_use_deprecated_uidplus_data: :up_to_max_size,
232-
parser_max_deprecated_uidplus_data_size: 100
233-
})
234-
response = parser.parse("A004 OK [APPENDUID 1 101:200] Done\r\n")
235-
assert_instance_of Net::IMAP::UIDPlusData, response.data.code.data
236-
response = parser.parse("A004 OK [APPENDUID 1 100:200] Done\r\n")
237-
assert_instance_of Net::IMAP::AppendUIDData, response.data.code.data
238-
end
239-
240-
test "APPENDUID with parser_use_deprecated_uidplus_data = false" do
241-
parser = Net::IMAP::ResponseParser.new(config: {
242-
parser_use_deprecated_uidplus_data: false,
243-
parser_max_deprecated_uidplus_data_size: 10_000_000,
244-
})
245-
response = parser.parse("A004 OK [APPENDUID 1 10] Done\r\n")
246-
assert_instance_of Net::IMAP::AppendUIDData, response.data.code.data
247-
end
248-
249204
test "COPYUID with backwards ranges" do
250205
parser = Net::IMAP::ResponseParser.new
251206
response = parser.parse(
@@ -276,53 +231,4 @@ def test_fetch_binary_and_binary_size
276231
end
277232
end
278233

279-
test "COPYUID with parser_use_deprecated_uidplus_data = true" do
280-
parser = Net::IMAP::ResponseParser.new(config: {
281-
parser_use_deprecated_uidplus_data: true,
282-
parser_max_deprecated_uidplus_data_size: 10_000,
283-
})
284-
assert_raise_with_message Net::IMAP::ResponseParseError, /uid-set is too large/ do
285-
parser.parse(
286-
"A004 OK [copyUID 1 10000:20000,1 1:10001] Done\r\n"
287-
)
288-
end
289-
response = parser.parse("A004 OK [copyUID 1 100:200 1:101] Done\r\n")
290-
uidplus = response.data.code.data
291-
assert_equal 101, uidplus.assigned_uids.size
292-
assert_equal 101, uidplus.source_uids.size
293-
parser.config.parser_max_deprecated_uidplus_data_size = 100
294-
assert_raise_with_message Net::IMAP::ResponseParseError, /uid-set is too large/ do
295-
parser.parse(
296-
"A004 OK [copyUID 1 100:200 1:101] Done\r\n"
297-
)
298-
end
299-
response = parser.parse("A004 OK [copyUID 1 101:200 1:100] Done\r\n")
300-
uidplus = response.data.code.data
301-
assert_instance_of Net::IMAP::UIDPlusData, uidplus
302-
assert_equal 100, uidplus.assigned_uids.size
303-
assert_equal 100, uidplus.source_uids.size
304-
end
305-
306-
test "COPYUID with parser_use_deprecated_uidplus_data = :up_to_max_size" do
307-
parser = Net::IMAP::ResponseParser.new(config: {
308-
parser_use_deprecated_uidplus_data: :up_to_max_size,
309-
parser_max_deprecated_uidplus_data_size: 100
310-
})
311-
response = parser.parse("A004 OK [COPYUID 1 101:200 1:100] Done\r\n")
312-
copyuid = response.data.code.data
313-
assert_instance_of Net::IMAP::UIDPlusData, copyuid
314-
response = parser.parse("A004 OK [COPYUID 1 100:200 1:101] Done\r\n")
315-
copyuid = response.data.code.data
316-
assert_instance_of Net::IMAP::CopyUIDData, copyuid
317-
end
318-
319-
test "COPYUID with parser_use_deprecated_uidplus_data = false" do
320-
parser = Net::IMAP::ResponseParser.new(config: {
321-
parser_use_deprecated_uidplus_data: false,
322-
parser_max_deprecated_uidplus_data_size: 10_000_000,
323-
})
324-
response = parser.parse("A004 OK [COPYUID 1 101 1] Done\r\n")
325-
assert_instance_of Net::IMAP::CopyUIDData, response.data.code.data
326-
end
327-
328234
end

test/net/imap/test_uidplus_data.rb

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,6 @@
33
require "net/imap"
44
require "test/unit"
55

6-
class TestUIDPlusData < Net::IMAP::TestCase
7-
8-
test "#uid_mapping with sorted source_uids" do
9-
uidplus = Net::IMAP::UIDPlusData.new(
10-
1, [19, 20, *(495..500)], [*(92..97), 100, 101],
11-
)
12-
assert_equal(
13-
{
14-
19 => 92,
15-
20 => 93,
16-
495 => 94,
17-
496 => 95,
18-
497 => 96,
19-
498 => 97,
20-
499 => 100,
21-
500 => 101,
22-
},
23-
uidplus.uid_mapping
24-
)
25-
end
26-
27-
test "#uid_mapping for with source_uids in unsorted order" do
28-
uidplus = Net::IMAP::UIDPlusData.new(
29-
1, [*(495..500), 19, 20], [*(92..97), 100, 101],
30-
)
31-
assert_equal(
32-
{
33-
495 => 92,
34-
496 => 93,
35-
497 => 94,
36-
498 => 95,
37-
499 => 96,
38-
500 => 97,
39-
19 => 100,
40-
20 => 101,
41-
},
42-
uidplus.uid_mapping
43-
)
44-
end
45-
46-
end
47-
486
class TestAppendUIDData < Net::IMAP::TestCase
497
# alias for convenience
508
AppendUIDData = Net::IMAP::AppendUIDData

0 commit comments

Comments
 (0)