id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,branch,branch_author,launchpad_bug
1977,unexpected search command breaks imap search,tvachon,,"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.
",defect,closed,high,,mail,fixed,imap4,exarkun tvachon,branches/imap4-search-1977-2,"therve, itamar, exarkun",
