IMAP folder path encoding (IMAP UTF-7) for Python

前端 未结 4 1651
感动是毒
感动是毒 2020-12-19 05:15

I would like to know if any \"official\" function/library existed in Python for IMAP4 UTF-7 folder path encoding.

In the imapInstance.list() I get the f

4条回答
  •  -上瘾入骨i
    2020-12-19 05:48

    The imapclient implementation is kind of broken though:

    x = "foo\rbar\n\n\n\r\r"
    imap_utf7.decode(imap_utf7.encode(x))
    

    Result:

    >> 'foo&bar\n\n\r-'
    

    Edit:

    After some research I found an implementation in MailPile which does not fail at roundtrip encoding on this test. I also ported it to Python3 if you're interested: https://github.com/MarechJ/py3_imap_utf7

提交回复
热议问题