Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parsing mail with pgp attachment #18

Closed
t0mmar opened this issue Jul 19, 2019 · 1 comment
Closed

Error parsing mail with pgp attachment #18

t0mmar opened this issue Jul 19, 2019 · 1 comment
Labels
bug Something isn't working standard deviation Missing or falsely implemented part of a supported standard
Projects

Comments

@t0mmar
Copy link
Contributor

t0mmar commented Jul 19, 2019

Bug description
Throws an exception when doing FETCH of BODYSTRUCTURE of a pgp-encrypted message

To Reproduce
Use gpg and Thunderbird to encrypt and sign a message and then attempt to FETCH its BODYSTRUCTURE.

Expected behavior
Successfully parses BODYSTRUCTURE response without exceptions.

Additional context

Exception is thrown in _processBodyMultiPart:

  static Future<Map<String, dynamic>> _processBodyMultiPart(
      ImapBuffer buffer) async {
    Map<String, dynamic> results = {"BODIES": <Map<String, dynamic>>[]};
    ImapWord word = await buffer.readWord();
    while (word.type == ImapWordType.parenOpen) {
      buffer.unread(word.value);
      results["BODIES"].add(await _processBody(buffer));
      word = await buffer.readWord();
    }
    if (word.type != ImapWordType.string) {
      throw new SyntaxErrorException("Expected string, but got $word"); <<<--- HERE
    }

word.type == ImapWordType.nil at this point

Log:

flutter: [INFO] imap_client: C: A7 FETCH 1 (BODYSTRUCTURE)
flutter: [INFO] imap_client: S: * 1 FETCH (BODYSTRUCTURE (("application" "pgp-encrypted" NIL NIL NIL "quoted-printable" 10 NIL NIL NIL NIL)("application" "octet-stream" ("name" "encrypted.asc") NIL NIL "7bit" 2871 NIL ("inline" ("filename" "encrypted.asc")) NIL NIL) "encrypted" ("boundary" "----KV1DHT7MP87IMFT410O4TDRRPM94YK" "protocol" "application/pgp-encrypted") NIL NIL NIL))

A7 OK Fetch completed (0.001 + 0.000 secs).
@t0mmar t0mmar added the bug Something isn't working label Jul 19, 2019
@michaelspiss
Copy link
Owner

Thanks for reporting this bug. Seems like this has the same cause as #16. I will rewrite the bodystructure parser in the (near-ish) future, but don't have a lot of spare time at the moment. Pull requests are welcome if you find the bug!

@michaelspiss michaelspiss added this to the Stable release milestone Jul 31, 2019
@michaelspiss michaelspiss added this to To do in Stable via automation Jul 31, 2019
@michaelspiss michaelspiss added the standard deviation Missing or falsely implemented part of a supported standard label Jul 31, 2019
Stable automation moved this from To do to Done Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working standard deviation Missing or falsely implemented part of a supported standard
Projects
Stable
  
Done
Development

No branches or pull requests

2 participants