Skip to content

Commit 0707ccb

Browse files
taku0nevans
authored andcommitted
🐛 Fix #header_fld_name to handle quoted strings correctly
1 parent eea091e commit 0707ccb

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/net/imap/response_parser.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,8 @@ def header_fld_name
13391339
assert_no_lookahead
13401340
start = @pos
13411341
astring
1342-
@str[start...@pos - 1]
1342+
end_pos = @token ? @pos - 1 : @pos
1343+
@str[start...end_pos]
13431344
end
13441345

13451346
# mailbox-data = "FLAGS" SP flag-list / "LIST" SP mailbox-list /

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@
6161
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n\r\n"
6262
raw_data: *test_fetch_msg_att_HEADER_FIELDS
6363

64+
test_fetch_msg_att_HEADER.FIELDS_quoted:
65+
:response: &test_fetch_msg_att_HEADER_FIELDS_quoted
66+
"* 10 FETCH (BODY[HEADER.FIELDS (\"Content-Type\")] {95}\r\nContent-Type: multipart/alternative;\r\n
67+
boundary=\"--==_mimepart_66cfb08b4f249_34306b61811e5\"\r\n\r\n)\r\n"
68+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
69+
name: FETCH
70+
data: !ruby/struct:Net::IMAP::FetchData
71+
seqno: 10
72+
attr:
73+
"BODY[HEADER.FIELDS (\"Content-Type\")]": "Content-Type: multipart/alternative;\r\n
74+
boundary=\"--==_mimepart_66cfb08b4f249_34306b61811e5\"\r\n\r\n"
75+
raw_data: *test_fetch_msg_att_HEADER_FIELDS_quoted
76+
6477
test_fetch_msg_att_HEADER.FIELDS.NOT:
6578
:response: &test_fetch_msg_att_HEADER_FIELDS_NOT
6679
"* 20368 FETCH (BODY[HEADER.FIELDS.NOT (Received DKIM-Signature List-Unsubscribe

0 commit comments

Comments
 (0)