modoboa-webmail icon indicating copy to clipboard operation
modoboa-webmail copied to clipboard

ParseError due to unsupported flag

Open awein opened this issue 6 years ago • 5 comments

Emails that use a flag value without a leading \ or $ will cause an internal error: ParseError: unexpected data_item found while looking for flag|right_parenthesis

Example: FLAGS (\Seen JUNK $Junk)

awein avatar Jun 06 '18 09:06 awein

@awein Which version of the webmail do you use?

tonioo avatar Jun 14 '18 08:06 tonioo

@tonioo Sorry for not mentioning the versions: Modoboa: 1.10.5 Webmail: 1.4.3

awein avatar Jun 14 '18 09:06 awein

That's strange, the regex cleary allows this kind of token: https://github.com/modoboa/modoboa-webmail/blob/master/modoboa_webmail/lib/fetch_parser.py#L93

tonioo avatar Jun 14 '18 09:06 tonioo

Sure - but JUNK will be treated as data_item type since it's matching that RE first. I had a quick look too but don't think there is an easy fix without reworking the Lexer class.

This snippet should be enough to reproduce the issue:

FetchResponseParser().parse_chunk('1 (UID 1303 FLAGS (\Seen NOTJUNK $NotJunk) RFC822.SIZE 5710 BODYSTRUCTURE ("text" "plain" ("charset" "ISO-8859-15") NIL NIL "quoted-printable" 2634 56 NIL NIL NIL NIL) BODY[HEADER.FIELDS (DATE FROM TO CC SUBJECT)] {154}')

awein avatar Jun 14 '18 12:06 awein

Indeed, there is a lexer rule conflict and the fix is more complicated than expected...

tonioo avatar Jul 16 '18 07:07 tonioo