Skip to content

Parsing failure: Strict whitespace handling on FETCH responses (extra space before closing parenthesis) #190

@rustmailer

Description

@rustmailer

I’m currently using imap-proto for a mail archiving project and have encountered a parsing issue with FETCH responses. It seems the parser is strictly rejecting responses that contain a space before the closing parenthesis in certain fields.

#[test]
fn test_fetch2222() {
    parse_response(b"* 11784 FETCH (UID 87567 INTERNALDATE \"06-May-2023 18:48:30 +0200\" RFC822.SIZE 5799845 )\r\n").unwrap();
}

The parser fails on this pattern:
RFC822.SIZE 5799845 )

If I remove the space (RFC822.SIZE 5799845), it parses correctly.

#[test]
fn test_fetch2222() {
    parse_response(b"* 11784 FETCH (UID 87567 INTERNALDATE \"06-May-2023 18:48:30 +0200\" RFC822.SIZE 5799845)\r\n").unwrap();
}

It appears the grammar definition is strictly expecting the closing ) immediately after the value. However, we have observed that some real-world IMAP servers include this space.

Is this strictness intentional per the RFC? If so, would you be open to a PR that makes the parser more tolerant of optional whitespace in these response structures to improve compatibility with real-world servers?

Thanks for your time and for maintaining this library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions