Skip to content

Commit

Permalink
🔀 Merge pull request #315 from taku0/fix_header_fld_name
Browse files Browse the repository at this point in the history
🐛 Fix #header_fld_name to handle quoted strings correctly
  • Loading branch information
nevans authored Sep 2, 2024
2 parents a2b0ea3 + 61e475d commit 74a39b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/net/imap/response_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,8 @@ def header_fld_name
assert_no_lookahead
start = @pos
astring
@str[start...@pos - 1]
end_pos = @token ? @pos - 1 : @pos
@str[start...end_pos]
end

# mailbox-data = "FLAGS" SP flag-list / "LIST" SP mailbox-list /
Expand Down
13 changes: 13 additions & 0 deletions test/net/imap/fixtures/response_parser/fetch_responses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n\r\n"
raw_data: *test_fetch_msg_att_HEADER_FIELDS

test_fetch_msg_att_HEADER.FIELDS_quoted:
:response: &test_fetch_msg_att_HEADER_FIELDS_quoted
"* 10 FETCH (BODY[HEADER.FIELDS (\"Content-Type\")] {95}\r\nContent-Type: multipart/alternative;\r\n
boundary=\"--==_mimepart_66cfb08b4f249_34306b61811e5\"\r\n\r\n)\r\n"
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
name: FETCH
data: !ruby/struct:Net::IMAP::FetchData
seqno: 10
attr:
"BODY[HEADER.FIELDS (\"Content-Type\")]": "Content-Type: multipart/alternative;\r\n
boundary=\"--==_mimepart_66cfb08b4f249_34306b61811e5\"\r\n\r\n"
raw_data: *test_fetch_msg_att_HEADER_FIELDS_quoted

test_fetch_msg_att_HEADER.FIELDS.NOT:
:response: &test_fetch_msg_att_HEADER_FIELDS_NOT
"* 20368 FETCH (BODY[HEADER.FIELDS.NOT (Received DKIM-Signature List-Unsubscribe
Expand Down

0 comments on commit 74a39b9

Please sign in to comment.