python / cpython

The Python programming language
https://www.python.org
Other
63.38k stars 30.35k forks source link

imaplib search() quoting search criteria #34114

Closed 46b0cf55-2dcd-488e-bb32-8b1b03d25e37 closed 23 years ago

46b0cf55-2dcd-488e-bb32-8b1b03d25e37 commented 23 years ago
BPO 406705
Nosy @tim-one, @smontanaro

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = 'https://github.com/smontanaro' closed_at = created_at = labels = ['library'] title = 'imaplib search() quoting search criteria' updated_at = user = 'https://bugs.python.org/b7kich' ``` bugs.python.org fields: ```python activity = actor = 'skip.montanaro' assignee = 'skip.montanaro' closed = True closed_date = None closer = None components = ['Library (Lib)'] creation = creator = 'b7kich' dependencies = [] files = [] hgrepos = [] issue_num = 406705 keywords = [] message_count = 4.0 messages = ['3768', '3769', '3770', '3771'] nosy_count = 3.0 nosy_names = ['tim.peters', 'skip.montanaro', 'b7kich'] pr_nums = [] priority = 'normal' resolution = 'works for me' stage = None status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue406705' versions = [] ```

46b0cf55-2dcd-488e-bb32-8b1b03d25e37 commented 23 years ago

Imaplib IMAP4.search() contains a bug in criteria handling: when sending a single word criterium it gets written to the stream well: M.search(None, 'ALL') produces: GINH16 SEARCH ALL

But a criterium with a white space will be quoted:

    M.search(None,'TEXT Hello')
produces in the tcp stream:
    GINH17 SEARCH "TEXT Hello"

which gets rejected because quotes are only allowed around the string, not the criterium: GINH17 SEARCH TEXT "Hello"

tim-one commented 23 years ago

Logged In: YES user_id=31435

Assigned to Skip at random.

smontanaro commented 23 years ago

Logged In: YES user_id=44345

This doesn't look like a bug to me. Looks like the search call is incorrect. I think it should be called as

    M.search(None, "TEXT", "Hello")

I've never used the imaplib stuff before, however. I'd welcome some input from someone who has.

Skip

smontanaro commented 23 years ago

Logged In: YES user_id=44345

Having heard nothing else on this, I'm going to conclude my reading of the code was correct and am closing it