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

Exception processing FETCH from Gmail #2

Closed
dmjones opened this issue Sep 21, 2018 · 3 comments
Closed

Exception processing FETCH from Gmail #2

dmjones opened this issue Sep 21, 2018 · 3 comments
Assignees
Labels
bug Something isn't working
Projects

Comments

@dmjones
Copy link

dmjones commented Sep 21, 2018

I received an unhandled exception when processing a FETCH operation from my Gmail account.

Here's the line from the server that triggered the error:

* 17989 FETCH (RFC822.SIZE 45339 INTERNALDATE "21-Sep-2018 12:05:58 +0000" FLAGS () ENVELOPE ("Fri, 21 Sep 2018 06:05:58 -0600" "Thank you for your donation to The Brain Tumour Charity" (("JustGiving" NIL "email" "contact.justgiving.com")) (("JustGiving" NIL

This is the command I sent:

var response = await client.fetch(uid.toString(), [
      "FLAGS",
      "INTERNALDATE",
      "RFC822.SIZE",
      "ENVELOPE",
      "BODY",
    ]);

And the exception:

Invalid argument(s): The string given is not a vaild imap list.
#0      ImapConverter.imapListToDartList (file:///Users/duncan/.pub-cache/hosted/pub.dartlang.org/imap_client-0.1.3/lib/src/imap_converter.dart:31:7)
#1      ImapConverter.imapListToDartMap (file:///Users/duncan/.pub-cache/hosted/pub.dartlang.org/imap_client-0.1.3/lib/src/imap_converter.dart:44:26)
#2      _ImapAnalyzer._handleSizeStatusUpdate (file:///Users/duncan/.pub-cache/hosted/pub.dartlang.org/imap_client-0.1.3/lib/src/imap_analyzer.dart:193:29)
#3      _ImapAnalyzer._handleLine (file:///Users/duncan/.pub-cache/hosted/pub.dartlang.org/imap_client-0.1.3/lib/src/imap_analyzer.dart:99:7)
#4      _ImapAnalyzer.analyzeLine (file:///Users/duncan/.pub-cache/hosted/pub.dartlang.org/imap_client-0.1.3/lib/src/imap_analyzer.dart:77:5)
#5      _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
@michaelspiss
Copy link
Owner

I have a feeling this is due to how parenthesis are handled by the analyzer, but I will have to take a deeper look at this.
Thanks for the detailed report!

@michaelspiss
Copy link
Owner

The error comes from the imapListToDartList() regex, which states that a list must not have any lists as children - which is the case here. This is fixed by removing "()" from the regex. This leads to another problem, the handling of lists within lists. Plus, I noticed that quotation marks don't keep a string together and prevent it from being split up.

Currently the output would be:

{ 'RFC822.SIZE': '45339', 'INTERNALDATE': '"21-Sep-2018', '12:05:58': '+0000"', 'FLAGS': '()', 'ENVELOPE': '("Fri,', '21': 'Sep', '2018': '06:05:58', '-0600"': '"Thank', 'you': 'for', 'your': 'donation', 'to': 'The', 'Brain': 'Tumour', 'Charity"': '(("JustGiving"', 'NIL': '', '"contact.justgiving.com"))': '(("JustGiving"' }

TODO:

  • Handle lists within lists
  • Handle strings in quotation marks

@michaelspiss michaelspiss self-assigned this Mar 4, 2019
@michaelspiss michaelspiss added the bug Something isn't working label Mar 4, 2019
@michaelspiss michaelspiss added this to In Progress in Rewrite Mar 4, 2019
@michaelspiss michaelspiss moved this from In Progress to Done in Rewrite Mar 7, 2019
@michaelspiss
Copy link
Owner

This issue has been fixed with the rewrite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Rewrite
  
Done
Development

No branches or pull requests

2 participants