Skip to content

Commit e6dfd50

Browse files
committed
Consider extra empty space in BODYSTRUCTURE
1 parent a32cd98 commit e6dfd50

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

lib/net/imap/response_parser.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,7 @@ def body_fields
11571157
def body_fld_param
11581158
return if NIL?
11591159
param = {}
1160+
shift_token if @token.symbol == T_SPACE
11601161
lpar
11611162
name = case_insensitive__string; SP!; param[name] = string
11621163
while SP?

test/net/imap/fixtures/response_parser/body_structure_responses.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,77 @@
433433
4383638 NIL (\"attachment\" (\"filename\" \"test.xml\")) NIL NIL) \"mixed\"
434434
(\"boundary\" \"001a1137a5047848e405157ddaa3\") NIL))\r\n"
435435

436+
test_bodystructure_extra_space:
437+
:response: "* 1 FETCH (UID 1 BODYSTRUCTURE (((\"text\" \"plain\" (\"charset\" \"UTF-8\") NIL
438+
NIL \"7bit\" 409 7 NIL NIL NIL)(\"text\" \"html\" (\"charset\" \"UTF-8\") NIL NIL \"7bit\"
439+
592 10 NIL NIL NIL) \"alternative\" (\"boundary\" \"--==_mimepart_5277b641dcc3_57d5887e8325d8\"
440+
\"charset\" \"UTF-8\") NIL NIL) \"mixed\" (\"boundary\" \"--==_mimepart_5277b64110f79_57d5887e832634\"
441+
\"charset\" \"UTF-8\") NIL NIL))\r\n"
442+
443+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
444+
name: FETCH
445+
data: !ruby/struct:Net::IMAP::FetchData
446+
seqno: 1
447+
attr:
448+
UID: 1
449+
BODYSTRUCTURE: !ruby/struct:Net::IMAP::BodyTypeMultipart
450+
media_type: MULTIPART
451+
subtype: MIXED
452+
parts:
453+
- !ruby/struct:Net::IMAP::BodyTypeMultipart
454+
media_type: MULTIPART
455+
subtype: ALTERNATIVE
456+
parts:
457+
- !ruby/struct:Net::IMAP::BodyTypeText
458+
media_type: TEXT
459+
subtype: PLAIN
460+
param:
461+
CHARSET: UTF-8
462+
content_id:
463+
description:
464+
encoding: 7BIT
465+
size: 409
466+
lines: 7
467+
md5:
468+
disposition:
469+
language:
470+
location:
471+
extension:
472+
- !ruby/struct:Net::IMAP::BodyTypeText
473+
media_type: TEXT
474+
subtype: HTML
475+
param:
476+
CHARSET: UTF-8
477+
content_id:
478+
description:
479+
encoding: 7BIT
480+
size: 592
481+
lines: 10
482+
md5:
483+
disposition:
484+
language:
485+
location:
486+
extension:
487+
param:
488+
BOUNDARY: --==_mimepart_5277b641dcc3_57d5887e8325d8
489+
CHARSET: UTF-8
490+
disposition:
491+
language:
492+
location:
493+
extension:
494+
param:
495+
BOUNDARY: --==_mimepart_5277b64110f79_57d5887e832634
496+
CHARSET: UTF-8
497+
disposition:
498+
language:
499+
location:
500+
extension:
501+
raw_data: "* 1 FETCH (UID 1 BODYSTRUCTURE (((\"text\" \"plain\" (\"charset\" \"UTF-8\") NIL NIL
502+
\"7bit\" 409 7 NIL NIL NIL)(\"text\" \"html\" (\"charset\" \"UTF-8\") NIL NIL \"7bit\"
503+
592 10 NIL NIL NIL) \"alternative\" (\"boundary\" \"--==_mimepart_5277b641dcc3_57d5887e8325d8\"
504+
\"charset\" \"UTF-8\") NIL NIL) \"mixed\" (\"boundary\" \"--==_mimepart_5277b64110f79_57d5887e832634\"
505+
\"charset\" \"UTF-8\") NIL NIL))\r\n"
506+
436507
test_bodystructure_mixed_boundary:
437508
:response: "* 2688 FETCH (UID 179161 BODYSTRUCTURE ((\"TEXT\" \"PLAIN\" (\"CHARSET\"
438509
\"iso-8859-1\") NIL NIL \"QUOTED-PRINTABLE\" 200 4 NIL NIL NIL)(\"MESSAGE\"

0 commit comments

Comments
 (0)