@@ -205,16 +205,43 @@ def test_fetch_binary_and_binary_size
205
205
test "APPENDUID with parser_use_deprecated_uidplus_data = true" do
206
206
parser = Net ::IMAP ::ResponseParser . new ( config : {
207
207
parser_use_deprecated_uidplus_data : true ,
208
+ parser_max_deprecated_uidplus_data_size : 10_000 ,
208
209
} )
210
+ assert_raise_with_message Net ::IMAP ::ResponseParseError , /uid-set is too large/ do
211
+ parser . parse (
212
+ "A004 OK [APPENDUID 1 10000:20000,1] Done\r \n "
213
+ )
214
+ end
215
+ response = parser . parse ( "A004 OK [APPENDUID 1 100:200] Done\r \n " )
216
+ uidplus = response . data . code . data
217
+ assert_equal 101 , uidplus . assigned_uids . size
218
+ parser . config . parser_max_deprecated_uidplus_data_size = 100
219
+ assert_raise_with_message Net ::IMAP ::ResponseParseError , /uid-set is too large/ do
220
+ parser . parse (
221
+ "A004 OK [APPENDUID 1 100:200] Done\r \n "
222
+ )
223
+ end
209
224
response = parser . parse ( "A004 OK [APPENDUID 1 101:200] Done\r \n " )
210
225
uidplus = response . data . code . data
211
226
assert_instance_of Net ::IMAP ::UIDPlusData , uidplus
212
227
assert_equal 100 , uidplus . assigned_uids . size
213
228
end
214
229
230
+ test "APPENDUID with parser_use_deprecated_uidplus_data = :up_to_max_size" do
231
+ parser = Net ::IMAP ::ResponseParser . new ( config : {
232
+ parser_use_deprecated_uidplus_data : :up_to_max_size ,
233
+ parser_max_deprecated_uidplus_data_size : 100
234
+ } )
235
+ response = parser . parse ( "A004 OK [APPENDUID 1 101:200] Done\r \n " )
236
+ assert_instance_of Net ::IMAP ::UIDPlusData , response . data . code . data
237
+ response = parser . parse ( "A004 OK [APPENDUID 1 100:200] Done\r \n " )
238
+ assert_instance_of Net ::IMAP ::AppendUIDData , response . data . code . data
239
+ end
240
+
215
241
test "APPENDUID with parser_use_deprecated_uidplus_data = false" do
216
242
parser = Net ::IMAP ::ResponseParser . new ( config : {
217
243
parser_use_deprecated_uidplus_data : false ,
244
+ parser_max_deprecated_uidplus_data_size : 10_000_000 ,
218
245
} )
219
246
response = parser . parse ( "A004 OK [APPENDUID 1 10] Done\r \n " )
220
247
assert_instance_of Net ::IMAP ::AppendUIDData , response . data . code . data
@@ -253,17 +280,47 @@ def test_fetch_binary_and_binary_size
253
280
test "COPYUID with parser_use_deprecated_uidplus_data = true" do
254
281
parser = Net ::IMAP ::ResponseParser . new ( config : {
255
282
parser_use_deprecated_uidplus_data : true ,
283
+ parser_max_deprecated_uidplus_data_size : 10_000 ,
256
284
} )
285
+ assert_raise_with_message Net ::IMAP ::ResponseParseError , /uid-set is too large/ do
286
+ parser . parse (
287
+ "A004 OK [copyUID 1 10000:20000,1 1:10001] Done\r \n "
288
+ )
289
+ end
290
+ response = parser . parse ( "A004 OK [copyUID 1 100:200 1:101] Done\r \n " )
291
+ uidplus = response . data . code . data
292
+ assert_equal 101 , uidplus . assigned_uids . size
293
+ assert_equal 101 , uidplus . source_uids . size
294
+ parser . config . parser_max_deprecated_uidplus_data_size = 100
295
+ assert_raise_with_message Net ::IMAP ::ResponseParseError , /uid-set is too large/ do
296
+ parser . parse (
297
+ "A004 OK [copyUID 1 100:200 1:101] Done\r \n "
298
+ )
299
+ end
257
300
response = parser . parse ( "A004 OK [copyUID 1 101:200 1:100] Done\r \n " )
258
301
uidplus = response . data . code . data
259
302
assert_instance_of Net ::IMAP ::UIDPlusData , uidplus
260
303
assert_equal 100 , uidplus . assigned_uids . size
261
304
assert_equal 100 , uidplus . source_uids . size
262
305
end
263
306
307
+ test "COPYUID with parser_use_deprecated_uidplus_data = :up_to_max_size" do
308
+ parser = Net ::IMAP ::ResponseParser . new ( config : {
309
+ parser_use_deprecated_uidplus_data : :up_to_max_size ,
310
+ parser_max_deprecated_uidplus_data_size : 100
311
+ } )
312
+ response = parser . parse ( "A004 OK [COPYUID 1 101:200 1:100] Done\r \n " )
313
+ copyuid = response . data . code . data
314
+ assert_instance_of Net ::IMAP ::UIDPlusData , copyuid
315
+ response = parser . parse ( "A004 OK [COPYUID 1 100:200 1:101] Done\r \n " )
316
+ copyuid = response . data . code . data
317
+ assert_instance_of Net ::IMAP ::CopyUIDData , copyuid
318
+ end
319
+
264
320
test "COPYUID with parser_use_deprecated_uidplus_data = false" do
265
321
parser = Net ::IMAP ::ResponseParser . new ( config : {
266
322
parser_use_deprecated_uidplus_data : false ,
323
+ parser_max_deprecated_uidplus_data_size : 10_000_000 ,
267
324
} )
268
325
response = parser . parse ( "A004 OK [COPYUID 1 101 1] Done\r \n " )
269
326
assert_instance_of Net ::IMAP ::CopyUIDData , response . data . code . data
0 commit comments