IMAP parser error in FETCH BODYSTRUCTURE response

RESOLVED FIXED

Status

MailNews Core
Networking: IMAP
RESOLVED FIXED
12 years ago
9 years ago

People

(Reporter: Henrik Gemal, Assigned: Bienvenu)

Tracking

({fixed1.8.1})

Trunk
x86
Windows XP
fixed1.8.1

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

12 years ago
using latest nightly thunderbird I'm unable to view a message:

3548[2307860]: 2307470:imap.mail.dk:S-INBOX:ProcessCurrentURL:imap://600002@imap.mail.dk:143/fetch%3EUID%3E/INBOX%3E22458:  = currentUrl
3548[2307860]: 2307470:imap.mail.dk:S-INBOX:SendData: 9 UID fetch 22458 (BODYSTRUCTURE)
3548[2307860]: ReadNextLine [stream=1e94430 nb=0 needmore=1]
3548[2307860]: ReadNextLine [stream=1e94430 nb=1733 needmore=0]
3548[2307860]: 2307470:imap.mail.dk:S-INBOX:CreateNewLineFromSocket: * 1 FETCH (BODYSTRUCTURE ((("text" "plain" ("charset" "ISO-8859-1") NIL NIL "quoted-printable" 6720 195)("text" "html" ("charset" "ISO-8859-1") NIL NIL "quoted-printable" 21524 420) "alternative" ("boundary" "---=mxea4innscspr53c8qgmx1t2jmcye1"))("image" "gif" ("name" "spacer.gif") "<mailhxoifgueqqxu3ns1xusa>" NIL "base64" 62)("image" "gif" ("name" "w_tl.gif") "<mailgumrax3m5cs78rirrvub>" NIL "bas
3548[2307860]: 2307470:imap.mail.dk:S-INBOX:PARSER:Internal Syntax Error: %s: * 1 FETCH (BODYSTRUCTURE ((("text" "plain" ("charset" "ISO-8859-1") NIL NIL "quoted-printable" 6720 195)("text" "html" ("charset" "ISO-8859-1") NIL NIL "quoted-printable" 21524 420) "alternative" ("boundary" "---=mxea4innscspr53c8qgmx1t2jmcye1"))("image" "gif" ("name" "spacer.gif") "<mailhxoifgueqqxu3ns1xusa>" NIL "base64" 62)("image" "gif" ("name" "w_tl.gif") "<mailgumrax3m5cs78rirrvub>" NIL "bas

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20051221 Thunderbird/1.6a1 ID:2005122111

I can provide a login to the mailbox if you contact me
(Assignee)

Comment 1

12 years ago
thx, yes, a login to the mailbox would be helpful (I might already have one but you'd need to refresh my memory).

What was the last good build you used?
(Reporter)

Comment 2

12 years ago
Created attachment 206613 [details]
mail that crashes the parser
(Reporter)

Comment 3

12 years ago
David: did you have a chance looking at the parser error?
(Assignee)

Comment 4

12 years ago
OK, reading this message with 1.5 works, because we fall back to fetching the whole message. Most likely we do that because we fail to parse the body structure, and fall back gracefully to the whole message. Hans-Andreas fixed a similar problem recently and I'm pretty sure I checked the fix in. I'll go try to figure out why that fix doesn't seem to be working for this case.

Comment 5

12 years ago
Henrik, could you please provide the full FETCH response in your log?  Either talk to your IMAP server directly via telnet, sniff your network traffic, or increase the hard-coded LINE_BUF_SIZE to 2048 in the following location,
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/nsprpub/pr/src/io/prlog.c&rev=3.34&root=/cvsroot&mark=153#145
(Solving Bug 244478 would remove this hard-coded limitation in NSPR log.)

Comment 6

12 years ago
I believe that David's analysis is correct.  Previously, when a syntax error occurred while parsing a BODYSTRUCTURE response, this error was silently ignored (and was not logged).  Since the BODYSTRUCTURE information is useful but not vital, Thunderbird/mozilla just continued to read the *whole* message from the server (instead of by parts) and the message was still accessible. 

However, since the IMAP parsing was consolidated in Bug 312599, parsing errors are reported (which is good) but not gracefully handled (which should be changed)!

So we should (i) fix the parser to properly read in the BODYSTRUCTURE reported here (if adheres to the IMAP protocol) and (ii) handle such parsing errors more gracefully (a similar issue was fixed in Bug 315975).
Depends on: 312599

Updated

12 years ago
Summary: getting "PARSER:Internal Syntax Error" → IMAP parser error in FETCH BODYSTRUCTURE response
(Assignee)

Comment 7

12 years ago
As near as I can tell, 1.0x thinks this is a valid body structure response, so I think we need to do i and ii. I'm going to look at ii first...
(Assignee)

Comment 8

12 years ago
Created attachment 206767 [details] [diff] [review]
hacky fix

this gets us back to the previous behaviour of more or less ignoring syntax errors in parsing the body structure response. What do you think, Hans-Andreas? I don't like just ignoring the error, but it sure seems like we used to do the same...

Comment 9

12 years ago
This short term fix looks very reasonable to me!  Maybe we should invoke |skip_to_CRLF();| after |SetSyntaxError(PR_FALSE)| as well, otherwise a syntax error might arise in
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/mailnews/imap/src/nsImapServerResponseParser.cpp&rev=1.133&root=/cvsroot&mark=239,240#230

I think that your patch reproduces the old behavior of gracefully handling a broken BODYSTRUCTURE (as long as there are no IMAP literals in the BODYSTRUCTURE, but this is usually not the case anyway).  And now errors are logged and an assertion is raised.
(Assignee)

Updated

12 years ago
Attachment #206767 - Flags: superreview?(mscott)

Updated

12 years ago
Attachment #206767 - Flags: superreview?(mscott) → superreview+
(Assignee)

Comment 10

12 years ago
fixed - this problem isn't on the 1.8.1 branch.
Status: NEW → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → FIXED
(Reporter)

Comment 11

12 years ago
Hans: Hopes this helps:

Doing imap by hand via telnet:

5 UID fetch 22458 (BODYSTRUCTURE)
* 1 FETCH (BODYSTRUCTURE ((("text" "plain" ("charset" "ISO-8859-1") NIL NIL "quoted-printable" 6720 195)("text" "html" ("charset" "ISO-8859-1") NIL NIL "quoted-printable" 21524 420) "alternative" ("boundary" "---=mxea4innscspr53c8qgmx1t2jmcye1"))("image" "gif" ("name" "spacer.gif") "<mailhxoifgueqqxu3ns1xusa>" NIL "base64" 62)("image" "gif" ("name" "w_tl.gif") "<mailgumrax3m5cs78rirrvub>" NIL "base64" 178)("image" "gif" ("name" "w_tr.gif") "<mailud0w3c8pdynlzebhqjvp>" NIL "base64" 178)("image" "gif" ("name" "logo.gif") "<mail8sazticdho3eknicykom>" NIL "base64" 2706)("image" "gif" ("name" "nyhedsbrev.gif") "<mailjo0mkk8rgeziiqlcudsn>" NIL "base64" 1802)("image" "gif" ("name" "w_bl.gif") "<mailsrdvgymgjbget4q97wnk>" NIL "base64" 174)("image" "gif" ("name" "w_br.gif") "<mailfgvow2oxhbanhahui4ja>" NIL "base64" 174)("image" "gif" ("name" "r_tl.gif") "<mailsnompkdyoa5opfqpgq74>" NIL "base64" 252)("image" "gif" ("name" "r_tr.gif") "<mailin7mo5oaggotpg1xoqi4>" NIL "base64" 252)("image" "gif" ("name" "pilxhvidx2.gif") "<mailb1kv7oddnutxycjdwoim>" NIL "base64" 84)("image" "gif" ("name" "r_bl.gif") "<mailm5kiozrxlkuqhhhlwqp8>" NIL "base64" 244)("image" "gif" ("name" "r_br.gif") "<mail6r3tx5clw536xlnpacdb>" NIL "base64" 244)("image" "gif" ("name" "pilxsortx2.gif") "<mailaey84hb0kugog1b6iiq0>" NIL "base64" 84)("image" "gif" ("name" "fox2005x04xforside.gif") "<mailnqnq2x4f5uynktlqu8nf>" NIL "base64" 29062)("image" "gif" ("name" "o_tl.gif") "<mailzjb3eaifzyvjecwfe9dg>" NIL "base64" 252)("image" "gif" ("name" "o_tr.gif") "<mailtxpyzx0ds0v6ekucccb4>" NIL "base64" 252)("image" "gif" ("name" "top6.gif") "<maildnkifmvaoicu9vpbpjbt>" NIL "base64" 1156) "related" ("boundary" "---=grjmf6judbu1z5i356wlw07dmlccax")) UID 22458)
5 OK UID FETCH completed

Updated

12 years ago
Keywords: fixed1.8.1
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.