twisted / twisted

Event-driven networking engine written in Python.
https://twisted.org
Other
5.55k stars 1.17k forks source link

IMAP4Client.lineReceived() fails to parse literals #2700

Closed twisted-trac closed 17 years ago

twisted-trac commented 17 years ago
jenner's avatar jenner reported
Trac ID trac#2700
Type defect
Created 2007-06-09 11:38:28Z

IMAP4Client.lineReceived() parses literals ({}) 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:

Searchable metadata ``` trac-id__2700 2700 type__defect defect reporter__jenner jenner priority__highest highest milestone__ branch__ branch_author__ status__closed closed resolution__fixed fixed component__mail mail keywords__mail_imap mail imap time__1181389108000000 1181389108000000 changetime__1181570904000000 1181570904000000 version__None None owner__ cc__therve ```
twisted-trac commented 17 years ago
exarkun's avatar @exarkun removed owner

Fixed in nested-imap4-literal-2700

twisted-trac commented 17 years ago
therve's avatar @therve set owner to @exarkun

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

twisted-trac commented 17 years ago
exarkun's avatar @exarkun set owner to @therve

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

twisted-trac commented 17 years ago
therve's avatar @therve set owner to @exarkun

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

Otherwise please merge.

twisted-trac commented 13 years ago
Automation's avatar Automation removed owner
twisted-trac commented 17 years ago
exarkun's avatar @exarkun set status to closed

(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.

twisted-trac commented 17 years ago
exarkun's avatar @exarkun commented

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

twisted-trac commented 17 years ago
jenner's avatar jenner commented

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@...>"))
0004 OK Fetch completed.