diff --git a/lib/net/imap/response_parser.rb b/lib/net/imap/response_parser.rb index fe6badc8..8fabb26d 100644 --- a/lib/net/imap/response_parser.rb +++ b/lib/net/imap/response_parser.rb @@ -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 / diff --git a/test/net/imap/fixtures/response_parser/fetch_responses.yml b/test/net/imap/fixtures/response_parser/fetch_responses.yml index 11d6905c..0ddad2e6 100644 --- a/test/net/imap/fixtures/response_parser/fetch_responses.yml +++ b/test/net/imap/fixtures/response_parser/fetch_responses.yml @@ -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