Opened 14 years ago

Closed 14 years ago

#2700 defect closed fixed (fixed)

IMAP4Client.lineReceived() fails to parse literals

Reported by: jenner Owned by:
Priority: highest Milestone:
Component: mail Keywords: mail imap
Cc: therve Branch:
Author:

Description

IMAP4Client.lineReceived() parses literals ({<octet>}) only if they are surrounded by whitespaces (like " {10} "), so if the server sends a response and puts a literal within a parenthesized list (e.g. " (({40}\n") the parser fails. The attached patch fixes this issue.

Attachments (2)

lineReceived.2.patch (767 bytes) - added by jenner 14 years ago.
A patch for IMAP4Client.lineReceived against trunk (revision: revision: source:/trunk/mail/imap4.py#18812)
lineReceived.patch (767 bytes) - added by jenner 14 years ago.
A patch for IMAP4Client.lineReceived against trunk (revision: revision: source:/trunk/twisted/mail/imap4.py#18812)

Download all attachments as: .zip

Change History (10)

Changed 14 years ago by jenner

Attachment: lineReceived.2.patch added

A patch for IMAP4Client.lineReceived against trunk (revision: revision: source:/trunk/mail/imap4.py#18812)

Changed 14 years ago by jenner

Attachment: lineReceived.patch added

A patch for IMAP4Client.lineReceived against trunk (revision: revision: source:/trunk/twisted/mail/imap4.py#18812)

comment:1 Changed 14 years ago by Jean-Paul Calderone

Can you attach a transcript of an IMAP4 session which includes a literal like this?

comment:2 in reply to:  1 Changed 14 years ago by jenner

Replying to exarkun:

Can you attach a transcript of an IMAP4 session which includes a literal like this?

Sure, here's the relevant part of the session (captured using tcpflow -C port 143, names and mail adresses changed keeping the original string size):

0004 FETCH 1:* (ENVELOPE)

* 1 FETCH (ENVELOPE ("Mon, 30 Oct 2006 08:40:56 -0600" "RE: Inherited property resolution" (({40}
Xxxxxxxxx, Yyyyyyyyy \(US - Glen Mills\) NIL "zzzzzzzzzz" "fooooooo.com")) (({40}
Xxxxxxxxx, Yyyyyyyyy \(US - Glen Mills\) NIL "zzzzzzzzzz" "fooooooo.com")) (("Maven Users List" NIL "users" "maven.apache.org")) ((NIL NIL "Abbb.Cdddddd" "ab.cdef.com")) ((NIL NIL "users" "maven.apache.org")) NIL NIL "<265E9EE670ED404DA5DBE42428204A4427F07D@uscnt0416.us.fooooooo.com>"))
0004 OK Fetch completed.

comment:3 Changed 14 years ago by Jean-Paul Calderone

Keywords: review added
Owner: Jean-Paul Calderone deleted
Priority: normalhighest

Fixed in nested-imap4-literal-2700

comment:4 Changed 14 years ago by therve

Cc: therve added
Owner: set to Jean-Paul Calderone

Looks good. If you feel it, lineReceived is missing a docstring, and the except ValueError path is not tested.

Otherwise please merge.

comment:5 Changed 14 years ago by Jean-Paul Calderone

Owner: changed from Jean-Paul Calderone to therve

Good points, both. Added a docstring and a unit test.

comment:6 Changed 14 years ago by therve

Keywords: review removed
Owner: changed from therve to Jean-Paul Calderone

Great. There a few trailing whitespaces in imap4.py, then you can merge.

comment:7 Changed 14 years ago by Jean-Paul Calderone

Resolution: fixed
Status: newclosed

(In [20526]) Merge nested-imap4-literal-2700

Author: exarkun Reviewer: therve Fixes #2700

Fix IMAP4Client's parsing of literals which are not preceeded by whitespace.

comment:8 Changed 11 years ago by <automation>

Owner: Jean-Paul Calderone deleted
Note: See TracTickets for help on using tickets.