Coder Social home page Coder Social logo

mjs / imapclient Goto Github PK

View Code? Open in Web Editor NEW
490.0 15.0 81.0 4.33 MB

An easy-to-use, Pythonic and complete IMAP client library

Home Page: https://imapclient.readthedocs.io/

License: Other

Shell 0.27% Python 99.73%
python imap imap-client python-3 python-2

imapclient's Issues

Folder names with double quotes around them have the double quotes stripped

Originally reported by: Menno Smits (Bitbucket: mjs0)


In [1]: c.create_folder('"foo"')
Out[1]: 'Create completed.'

In [2]: c.create_folder('"foo" bar')
Out[2]: 'Create completed.'

In [3]: [x for x in c.list_folders() if 'foo' in str(x)]
Out[3]: [(['\\HasNoChildren'], '/', '"foo" bar'), (['\\HasNoChildren'], '/', 'foo')]

There could be similar issues with other folder handling methods.


fetch ENVELOPE doesn't work with gmail

Originally reported by: Anonymous


>>> server.select_folder('william')
7L
>>> server.fetch(1, ("ENVELOPE",))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "imapclient/imapclient.py", line 436, in fetch
    return parser(data)
  File "imapclient/imapclient.py", line 573, in parse
    msgid, data = self.parse_data(response_item)
  File "imapclient/imapclient.py", line 614, in parse_data
    for name, item in FetchTokeniser().process_pairs(data):
  File "imapclient/imapclient.py", line 699, in process_pairs
    for m in strict_finditer(self.PAIR_RE, s):
  File "imapclient/imapclient.py", line 763, in strict_finditer
    "%r before -- %r remains" % (s[:i], s[i:]))
ValueError: failed to match all of input. 'UID 1 ENVELOPE ("Fri, 16 Jul 2004 15:59:43 -0400" "on my way" (("Mark Eichin" NIL "eichin" "gmail.com")' before -- ') (("Mark Eichin" NIL "eichin" "gmail.com")) (("Mark Eichin" NIL "eichin" "gmail.com")) (("Other Person" NIL "..." "...")) NIL NIL NIL "<[email protected]>")' remains

(email address parts elided from one of the strings, but the match has already failed at that point. Also, this is with strict_finditer tweaked as-shown so you can see the successful part of the match as well as the failed part...)

It appears that this is what keeps fetch(1, ("ALL",)) from working, as well, it hits the !ValueError in the same place at least, and the other parts of ALL work when fetched individually.


Work around imaplib SSL bug

Originally reported by: Menno Smits (Bitbucket: mjs0)


Details from Mark:

In short, there is a bug in imaplib when dealing with ssl connections
which terminate early - the SSL readline() method in imaplib gets into
a loop reading empty strings from the socket and appending them to a
list, chewing lots of memory and causing some consternation :)

The bug seems to be http://bugs.python.org/issue5949 and it has been
fixed in various versions, although I hit it in 2.6.3.

It was fixed in 2.6 in:
http://svn.python.org/view/python/branches/release26-maint/Lib/imaplib.py?r1=76761&r2=76760&pathrev=76761

But note that it has not been back-ported to 2.5 or earlier.

The bug report above includes a patch to imaplib's readline. It should
be possible to monkeypatch in the fixed version if a buggy imaplib
version is detected.


nicer ENVELOPE parsing

Originally reported by: Menno Smits (Bitbucket: mjs0)


ENVELOPE fetch response items are curently just a nested set of tuples. A richer data structure would be friendlier to use. ENVELOPE responses should have helper properties/methods for getting the addresses out (and more?) and named attributes for each field.


Genshi UnicodeDecode error from trac:

Originally reported by: Anonymous


I get this error when posting a ticket (which is why 29 and 30 are duplicates, sorry) - the posting works, but I can't see the resulting ticket...

Trac Error

Genshi UnicodeDecodeError error while rendering template (unknown template location)

TracGuide โ€” The Trac User and Administration Guide


fetch ENVELOPE doesn't work with gmail

Originally reported by: anonymous (Bitbucket: anonymous)


>>> server.select_folder('william')
7L
>>> server.fetch(1, ("ENVELOPE",))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "imapclient/imapclient.py", line 436, in fetch
    return parser(data)
  File "imapclient/imapclient.py", line 573, in parse
    msgid, data = self.parse_data(response_item)
  File "imapclient/imapclient.py", line 614, in parse_data
    for name, item in FetchTokeniser().process_pairs(data):
  File "imapclient/imapclient.py", line 699, in process_pairs
    for m in strict_finditer(self.PAIR_RE, s):
  File "imapclient/imapclient.py", line 763, in strict_finditer
    "%r before -- %r remains" % (s[:i], s[i:]))
ValueError: failed to match all of input. 'UID 1 ENVELOPE ("Fri, 16 Jul 2004 15:59:43 -0400" "on my way" (("Mark Eichin" NIL "eichin" "gmail.com")' before -- ') (("Mark Eichin" NIL "eichin" "gmail.com")) (("Mark Eichin" NIL "eichin" "gmail.com")) (("Other Person" NIL "..." "...")) NIL NIL NIL "<[email protected]>")' remains

(email address parts elided from one of the strings, but the match has already failed at that point.  Also, this is with strict_finditer tweaked as-shown so you can see the successful part of the match as well as the failed part...)

It appears that this is what keeps fetch(1, ("ALL",)) from working, as well, it hits the ValueError in the same place at least, and the other parts of ALL work when fetched individually.

Return LIST style responses as namedtuples

Originally reported by: Menno Smits (Bitbucket: mjs0)


Currently methods that return lists of folder name objects return (flags, delim, name) triples. It would be friendlier if these where namedtuples with "flags", "delimiter" and "name" attributes.

This avoids breaking the existing positional API while adding convenience (and avoiding magic numbers).

Example:

folders = client.list_folders()
folder = folders[0]

assert folder.flags == folder[0]
assert folder.delim == folder[1]
assert folder.name == folder[2]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.