Ticket #1978 defect closed fixed
fetch [message number] body[1] processed incorrectly for non-multipart messages
| Reported by: | tvachon | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | Keywords: | imap4 | |
| Cc: | Branch: | ||
| Author: | Launchpad Bug: |
Description
According to rfc 2060, a command like
000001 FETCH 1 BODY[1]
should be legal for non-multipart messages, since
Every message has at least one part number. Non-[MIME-IMB] messages, and non-multipart [MIME-IMB] messages with no encapsulated message, only have a part 1.
Currently, Twisted responds to this command by calling IMessagePart.getSubPart (twisted/imap4.py:1726):
def spew_body(self, part, id, msg, _w=None, _f=None):
if _w is None:
_w = self.transport.write
for p in part.part:
msg = msg.getSubPart(p)
if part.header:
...
but according to the twisted.mail.imap4.IMessagePart interface, IMessage.getSubPart should raise a TypeError for non-multipart messages.
The fix is to replace
def spew_body(self, part, id, msg, _w=None, _f=None):
if _w is None:
_w = self.transport.write
for p in part.part:
msg = msg.getSubPart(p)
if part.header:
...
with
def spew_body(self, part, id, msg, _w=None, _f=None):
if _w is None:
_w = self.transport.write
for p in part.part:
if msg.isMultipart():
msg = msg.getSubPart(p)
else:
if p > 0:
raise TypeError, "Requested subpart of non-multipart message"
if part.header:
...
This will raise a type error for the non-sensical query
00001 FETCH 1 BODY[2]
on a non-multipart message, but will make
00001 FETCH 1 BODY[1]
conform to the standard to non-multipart messages.
I have only seen this issue using Pine, but since it breaks compatibility with Pine I have marked this as High priority.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

