Issue23779
Created on 2015-03-25 22:21 by craigh, last changed 2015-07-30 21:04 by rbcollins. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| imap_auth.patch | craigh, 2015-03-25 22:21 | imaplib.py patch | review | |
| imap_auth2.patch | craigh, 2015-03-31 02:51 | review | ||
| imap_auth3.patch | craigh, 2015-03-31 21:46 | review | ||
| Messages (8) | |||
|---|---|---|---|
| msg239283 - (view) | Author: Craig Holmquist (craigh) | Date: 2015-03-25 22:21 | |
If the authenticator object passed to the IMAP authenticate method tries to abort the handshake by returning None, TypeError is raised instead of sending the * line to the server.
>>> import imaplib
>>> imap = imaplib.IMAP4_SSL('imap.gmail.com')
>>> imap.authenticate(b'PLAIN', lambda x: None)
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
imap.authenticate(b'PLAIN', lambda x: None)
File "C:\Python34\lib\imaplib.py", line 380, in authenticate
typ, dat = self._simple_command('AUTHENTICATE', mech)
File "C:\Python34\lib\imaplib.py", line 1133, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "C:\Python34\lib\imaplib.py", line 940, in _command
self.send(literal)
File "C:\Python34\lib\imaplib.py", line 276, in send
self.sock.sendall(data)
File "C:\Python34\lib\ssl.py", line 723, in sendall
v = self.send(data[count:])
File "C:\Python34\lib\ssl.py", line 684, in send
v = self._sslobj.write(data)
TypeError: 'str' does not support the buffer interface
The problem is that _Authenticator.process returns a string instead of bytes in this case.
|
|||
| msg239656 - (view) | Author: Berker Peksag (berker.peksag) * | Date: 2015-03-31 02:25 | |
Thanks for the report and the patch, Craig. Could you convert your reproducer to a test case? imaplib tests are located in Lib/test/test_imaplib.py. |
|||
| msg239658 - (view) | Author: Craig Holmquist (craigh) | Date: 2015-03-31 02:51 | |
New patch is attached. |
|||
| msg239701 - (view) | Author: R. David Murray (r.david.murray) * | Date: 2015-03-31 13:12 | |
The patch looks good to me, except that I think it would be better if the test verified that the '*' response is received by the server (perhaps return OK if we don't get it?) |
|||
| msg239752 - (view) | Author: Craig Holmquist (craigh) | Date: 2015-03-31 21:46 | |
Okay, I attached another patch. The new version of the test returns success if the client's response is anything other than the abort line (*\r\n). It fails with the current version of imaplib, fails if I change _Authenticator.process to output a byte-string besides *, and succeeds with the change in the patch. |
|||
| msg239803 - (view) | Author: R. David Murray (r.david.murray) * | Date: 2015-04-01 13:20 | |
Looks good to me, thanks. |
|||
| msg247698 - (view) | Author: Roundup Robot (python-dev) | Date: 2015-07-30 21:03 | |
New changeset fe55a36a335b by Robert Collins in branch '3.4': Issue #23779: imaplib raises TypeError if authenticator tries to abort. https://hg.python.org/cpython/rev/fe55a36a335b New changeset b6f04b9d8c12 by Robert Collins in branch '3.5': Issue #23779: imaplib raises TypeError if authenticator tries to abort. https://hg.python.org/cpython/rev/b6f04b9d8c12 New changeset 0879f2c53289 by Robert Collins in branch 'default': Issue #23779: imaplib raises TypeError if authenticator tries to abort. https://hg.python.org/cpython/rev/0879f2c53289 |
|||
| msg247699 - (view) | Author: Robert Collins (rbcollins) * | Date: 2015-07-30 21:04 | |
Thanks for the patch. Applied to 3.4 through 3.6. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2015-07-30 21:04:24 | rbcollins | set | status: open -> closed nosy:
+ rbcollins resolution: fixed |
| 2015-07-30 21:03:42 | python-dev | set | nosy:
+ python-dev messages: + msg247698 |
| 2015-04-01 13:20:55 | r.david.murray | set | messages:
+ msg239803 stage: patch review -> commit review |
| 2015-03-31 21:46:30 | craigh | set | files:
+ imap_auth3.patch messages: + msg239752 |
| 2015-03-31 13:12:28 | r.david.murray | set | nosy:
+ barry, r.david.murray messages: + msg239701 components:
+ email |
| 2015-03-31 02:51:15 | craigh | set | files:
+ imap_auth2.patch messages: + msg239658 |
| 2015-03-31 02:25:43 | berker.peksag | set | nosy:
+ berker.peksag messages:
+ msg239656 |
| 2015-03-25 23:17:21 | eric.smith | set | nosy:
+ eric.smith |
| 2015-03-25 23:16:22 | eric.smith | set | stage: test needed |
| 2015-03-25 22:21:23 | craigh | create | |