Skip to content

imaplib - bug/regression on login command with 3.14.7 #155775

Description

@QHivert

Bug report

Bug description:

Hello!

I notice a change of behavior with imaplib login command starting with 3.14.7. It was working fine with 3.14.6 and previous version.

However, I'm not sure if what happens with 3.14.7 is the right way and a correction or not.

Problem

In imap, after a successful login command like this, the response also has the capabilities

$ telnet 127.0.0.1 143

Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ STARTTLS AUTH=PLAIN AUTH=LOGIN AUTH=XOAUTH2] Dovecot ready.
1 LOGIN username password
1 OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY PREVIEW=FUZZY PREVIEW STATUS=SIZE SAVEDATE LITERAL+ NOTIFY QUOTA ACL RIGHTS=texk] Logged in.

The way to get those capabilities with imaplib has changed in 3.14.7

Prior 3.14.7, (works in 3.14.6 and prior)

To get those capabilities, I have to do that:

# Assume conn is a proper imaplib.IMAP4 object
conn.login(user, password)
cap_ret = conn.response('CAPABILITY')
# cap_ret = ('CAPABILITY', [b'bla blou bli']) with bla blou bli the capabilities

With imaplib.Debug = 4, notice the answer in two parts

20:46.30 > b'NDMB1 LOGIN [username](mailto:username) "password"'
20:46.32 < b'* CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY PREVIEW=FUZZY PREVIEW STATUS=SIZE SAVEDATE LITERAL+ NOTIFY QUOTA ACL RIGHTS=texk'
20:46.32 < b'NDMB1 OK Logged in'

With 3.14.7

With imaplib.Debug = 4, notice that the answer is is one part

22:31.17 > b'EHKG0 LOGIN LOGIN [username](mailto:username) "password"'
22:31.19 < b'EHKG0 OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY PREVIEW=FUZZY PREVIEW STATUS=SIZE SAVEDATE LITERAL+ NOTIFY QUOTA ACL RIGHTS=texk] Logged in'

And in python:

# Assume conn is a proper imaplib.IMAP4 object
conn.login(user, password)
cap_ret = conn.response('CAPABILITY')
# cap_ret is now = ('CAPABILITY', [None]) because there is no response "* CAPABILITY"

Now I have to parse the response of conn.login() to get the capabilities.

Conclusion

I'm not sure which of 3.14.7 or previous version is the expected way for that. However, I would have to implement the two methods if I want my app to work whatever the 3.14.x.

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions