@@ -214,16 +214,43 @@ def test_fetch_binary_and_binary_size
214
214
test "APPENDUID with parser_use_deprecated_uidplus_data = true" do
215
215
parser = Net ::IMAP ::ResponseParser . new ( config : {
216
216
parser_use_deprecated_uidplus_data : true ,
217
+ parser_max_deprecated_uidplus_data_size : 10_000 ,
217
218
} )
219
+ assert_raise_with_message Net ::IMAP ::ResponseParseError , /uid-set is too large/ do
220
+ parser . parse (
221
+ "A004 OK [APPENDUID 1 10000:20000,1] Done\r \n "
222
+ )
223
+ end
224
+ response = parser . parse ( "A004 OK [APPENDUID 1 100:200] Done\r \n " )
225
+ uidplus = response . data . code . data
226
+ assert_equal 101 , uidplus . assigned_uids . size
227
+ parser . config . parser_max_deprecated_uidplus_data_size = 100
228
+ assert_raise_with_message Net ::IMAP ::ResponseParseError , /uid-set is too large/ do
229
+ parser . parse (
230
+ "A004 OK [APPENDUID 1 100:200] Done\r \n "
231
+ )
232
+ end
218
233
response = parser . parse ( "A004 OK [APPENDUID 1 101:200] Done\r \n " )
219
234
uidplus = response . data . code . data
220
235
assert_instance_of Net ::IMAP ::UIDPlusData , uidplus
221
236
assert_equal 100 , uidplus . assigned_uids . size
222
237
end
223
238
239
+ test "APPENDUID with parser_use_deprecated_uidplus_data = :up_to_max_size" do
240
+ parser = Net ::IMAP ::ResponseParser . new ( config : {
241
+ parser_use_deprecated_uidplus_data : :up_to_max_size ,
242
+ parser_max_deprecated_uidplus_data_size : 100
243
+ } )
244
+ response = parser . parse ( "A004 OK [APPENDUID 1 101:200] Done\r \n " )
245
+ assert_instance_of Net ::IMAP ::UIDPlusData , response . data . code . data
246
+ response = parser . parse ( "A004 OK [APPENDUID 1 100:200] Done\r \n " )
247
+ assert_instance_of Net ::IMAP ::AppendUIDData , response . data . code . data
248
+ end
249
+
224
250
test "APPENDUID with parser_use_deprecated_uidplus_data = false" do
225
251
parser = Net ::IMAP ::ResponseParser . new ( config : {
226
252
parser_use_deprecated_uidplus_data : false ,
253
+ parser_max_deprecated_uidplus_data_size : 10_000_000 ,
227
254
} )
228
255
response = parser . parse ( "A004 OK [APPENDUID 1 10] Done\r \n " )
229
256
assert_instance_of Net ::IMAP ::AppendUIDData , response . data . code . data
@@ -262,17 +289,47 @@ def test_fetch_binary_and_binary_size
262
289
test "COPYUID with parser_use_deprecated_uidplus_data = true" do
263
290
parser = Net ::IMAP ::ResponseParser . new ( config : {
264
291
parser_use_deprecated_uidplus_data : true ,
292
+ parser_max_deprecated_uidplus_data_size : 10_000 ,
265
293
} )
294
+ assert_raise_with_message Net ::IMAP ::ResponseParseError , /uid-set is too large/ do
295
+ parser . parse (
296
+ "A004 OK [copyUID 1 10000:20000,1 1:10001] Done\r \n "
297
+ )
298
+ end
299
+ response = parser . parse ( "A004 OK [copyUID 1 100:200 1:101] Done\r \n " )
300
+ uidplus = response . data . code . data
301
+ assert_equal 101 , uidplus . assigned_uids . size
302
+ assert_equal 101 , uidplus . source_uids . size
303
+ parser . config . parser_max_deprecated_uidplus_data_size = 100
304
+ assert_raise_with_message Net ::IMAP ::ResponseParseError , /uid-set is too large/ do
305
+ parser . parse (
306
+ "A004 OK [copyUID 1 100:200 1:101] Done\r \n "
307
+ )
308
+ end
266
309
response = parser . parse ( "A004 OK [copyUID 1 101:200 1:100] Done\r \n " )
267
310
uidplus = response . data . code . data
268
311
assert_instance_of Net ::IMAP ::UIDPlusData , uidplus
269
312
assert_equal 100 , uidplus . assigned_uids . size
270
313
assert_equal 100 , uidplus . source_uids . size
271
314
end
272
315
316
+ test "COPYUID with parser_use_deprecated_uidplus_data = :up_to_max_size" do
317
+ parser = Net ::IMAP ::ResponseParser . new ( config : {
318
+ parser_use_deprecated_uidplus_data : :up_to_max_size ,
319
+ parser_max_deprecated_uidplus_data_size : 100
320
+ } )
321
+ response = parser . parse ( "A004 OK [COPYUID 1 101:200 1:100] Done\r \n " )
322
+ copyuid = response . data . code . data
323
+ assert_instance_of Net ::IMAP ::UIDPlusData , copyuid
324
+ response = parser . parse ( "A004 OK [COPYUID 1 100:200 1:101] Done\r \n " )
325
+ copyuid = response . data . code . data
326
+ assert_instance_of Net ::IMAP ::CopyUIDData , copyuid
327
+ end
328
+
273
329
test "COPYUID with parser_use_deprecated_uidplus_data = false" do
274
330
parser = Net ::IMAP ::ResponseParser . new ( config : {
275
331
parser_use_deprecated_uidplus_data : false ,
332
+ parser_max_deprecated_uidplus_data_size : 10_000_000 ,
276
333
} )
277
334
response = parser . parse ( "A004 OK [COPYUID 1 101 1] Done\r \n " )
278
335
assert_instance_of Net ::IMAP ::CopyUIDData , response . data . code . data
0 commit comments