Skip to content

Commit 095d396

Browse files
committed
🐛 Fix unbalanced parens in body-fld-lang parsing
Oops! The bug was introduced by the rewrite in a00e2e3. This also adds examples to improve test coverage (including this bug).
1 parent eb8e65c commit 095d396

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

lib/net/imap/response_parser.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,7 @@ def body_fld_lang
967967
if lpar?
968968
result = [case_insensitive__string]
969969
result << case_insensitive__string while SP?
970+
rpar
970971
result
971972
else
972973
case_insensitive__nstring

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

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,87 @@
3636
extension:
3737
raw_data: "* 4902 FETCH (BODY ((\"MESSAGE\" \"DELIVERY-STATUS\" NIL NIL NIL \"7BIT\" 324) \"REPORT\"))\r\n"
3838

39+
test_bodystructure_extension_fields:
40+
:response: &test_bodystructure_extension_fields "* 161 FETCH (UID 25627 BODYSTRUCTURE ((\"TEXT\" \"PLAIN\" (\"CHARSET\" \"US-ASCII\") NIL NIL \"7BIT\" 1152 23 \"123456789abcdef\" (\"dsp-type\" (\"dsp-fld-param\" \"val1\" \"key2\" \"val2\")) (\"lang1\" \"lang2\") \"loc\" \"ext0\" 1 (2) \"ext3\" ((((((4)))))) (\"ext number\" 5))(\"TEXT\" \"PLAIN\" (\"CHARSET\" \"US-ASCII\" \"NAME\" \"trip.txt\") \"<[email protected]>\" \"Your trip details\" \"BASE64\" 4554 73 NiL NIL \"lang3\" \"loc...\" \"ext\" \"part deux\" \"electric boogaloo\") \"MIXED\" (\"ext\" \"mpart\" \"fld\" \"param\") (\"multi-dsp\" (\"multi dsp body-fld-param\" \"param value\")) (\"lang\" \"lang\" \"langy\" \"LANG\" \"lang\") \"location mclocation face\" \"extended release\" ((((((1) (2) (3)))) \"done\"))))\r\n"
41+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
42+
name: FETCH
43+
data: !ruby/struct:Net::IMAP::FetchData
44+
seqno: 161
45+
attr:
46+
UID: 25627
47+
BODYSTRUCTURE: !ruby/struct:Net::IMAP::BodyTypeMultipart
48+
media_type: MULTIPART
49+
subtype: MIXED
50+
parts:
51+
- !ruby/struct:Net::IMAP::BodyTypeText
52+
media_type: TEXT
53+
subtype: PLAIN
54+
param:
55+
CHARSET: US-ASCII
56+
content_id:
57+
description:
58+
encoding: 7BIT
59+
size: 1152
60+
lines: 23
61+
md5: 123456789abcdef
62+
disposition: !ruby/struct:Net::IMAP::ContentDisposition
63+
dsp_type: DSP-TYPE
64+
param:
65+
DSP-FLD-PARAM: val1
66+
KEY2: val2
67+
language:
68+
- LANG1
69+
- LANG2
70+
location: loc
71+
extension:
72+
- ext0
73+
- 1
74+
- - 2
75+
- ext3
76+
- - - - - - - 4
77+
- - ext number
78+
- 5
79+
- !ruby/struct:Net::IMAP::BodyTypeText
80+
media_type: TEXT
81+
subtype: PLAIN
82+
param:
83+
CHARSET: US-ASCII
84+
NAME: trip.txt
85+
content_id: "<[email protected]>"
86+
description: Your trip details
87+
encoding: BASE64
88+
size: 4554
89+
lines: 73
90+
md5:
91+
disposition:
92+
language: LANG3
93+
location: loc...
94+
extension:
95+
- ext
96+
- part deux
97+
- electric boogaloo
98+
param:
99+
EXT: mpart
100+
FLD: param
101+
disposition: !ruby/struct:Net::IMAP::ContentDisposition
102+
dsp_type: MULTI-DSP
103+
param:
104+
MULTI DSP BODY-FLD-PARAM: param value
105+
language:
106+
- LANG
107+
- LANG
108+
- LANGY
109+
- LANG
110+
- LANG
111+
location: location mclocation face
112+
extension:
113+
- extended release
114+
- - - - - - - 1
115+
- - 2
116+
- - 3
117+
- done
118+
raw_data: *test_bodystructure_extension_fields
119+
39120
test_bodystructure_bug7147_message_rfc822_attachment:
40121
:comments: |
41122
[Bug #7147]

0 commit comments

Comments
 (0)