Skip to content

Commit a9ea54d

Browse files
Alexander Krotovdjc
authored andcommitted
Parse HEADER.FIELDS
1 parent a356095 commit a9ea54d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

imap-proto/src/body.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ named!(pub section_part<Vec<u32>>, do_parse!(
1515
));
1616

1717
named!(pub section_msgtext<MessageSection>, alt!(
18+
do_parse!(
19+
tag_no_case!("HEADER.FIELDS") >>
20+
opt!(tag_no_case!(".NOT")) >>
21+
tag!(" ") >>
22+
parenthesized_list!(astring) >>
23+
(MessageSection::Header)) |
1824
do_parse!(tag_no_case!("HEADER") >> (MessageSection::Header)) |
1925
do_parse!(tag_no_case!("TEXT") >> (MessageSection::Text))
2026
));

imap-proto/src/parser/rfc3501.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,16 @@ mod tests {
674674
}
675675
}
676676

677+
#[test]
678+
fn test_header_fields() {
679+
const RESPONSE: &[u8] = b"* 1 FETCH (UID 1 BODY[HEADER.FIELDS (CHAT-VERSION)] {21}\r\nChat-Version: 1.0\r\n\r\n)\r\n";
680+
681+
match parse_response(RESPONSE) {
682+
Ok((_, Response::Fetch(_, _))) => {},
683+
rsp => panic!("unexpected response {:?}", rsp),
684+
}
685+
}
686+
677687
#[test]
678688
fn test_opt_addresses() {
679689
let addr = b"((NIL NIL \"minutes\" \"CNRI.Reston.VA.US\") (\"John Klensin\" NIL \"KLENSIN\" \"MIT.EDU\")) ";

0 commit comments

Comments
 (0)