Ticket #1977 defect closed fixed
unexpected search command breaks imap search
| Reported by: | tvachon | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | Keywords: | imap4 | |
| Cc: | exarkun, tvachon | Branch: | branches/imap4-search-1977-2 |
| Author: | therve, itamar, exarkun | Launchpad Bug: |
Description
twisted.mail.imap4.IMAP4Server.singleSearchStep has code to handle unexpected search commands, but this code cannot be reached (line 1466):
f = getattr(self, 'search_' + c)
if f:
if not f(query, id, msg):
return False
else:
# IMAP goes *out of its way* to be complex
# Sequence sets to search should be specified
# with a command, like EVERYTHING ELSE.
try:
m = parseIdList(c)
except:
log.err('Unknown search term: ' + c)
else:
if id not in m:
return False
Since f = getattr(self, 'search_' + c) raises an AttributeError if 'search_' + c does not exist, f can never evaluate to False, so the "else" suite never runs.
The fix is to replace
f = getattr(self, 'search_' + c)
with
f = getattr(self, 'search_' + c, None)
This problem arises from IMAP client commands like
00000003 SEARCH 1 UNDELETED UNSEEN
The only client I've seen use this is Pine, but since this does break compatibility with Pine, I've marked its priority as High.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

