This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author scott.dial
Recipients barry, benjamin.peterson, janssen, kevinwatters, ncoghlan, r.david.murray, rhettinger, rmore, rtucker, scott.dial
Date 2009-12-09.19:49:11
SpamBayes Score 4.082494e-06
Marked as misclassified No
Message-id <1260388153.68.0.204484005046.issue5949@psf.upfronthosting.co.za>
In-reply-to
Content
It seems that on the py3k branch, the EOF situation is handled roughly
in the same manner (the broken line is returned) and ultimately the
IMAP4.abort exception is raised because b'* ' is an invalid response
(the 'OK' having been dropped). IOW, it passes the EOF test only because
trimming broke the welcome message format. If it got an EOF in the
middle of a more complicated response, it would go undetected or cause a
broken response.

I propose adding the following test case:

    @reap_threads
    def test_line_termination(self):

        class BadNewlineHandler(SimpleIMAPHandler):

            def cmd_CAPABILITY(self, tag, args):
                self._send(b'* CAPABILITY IMAP4rev1 AUTH\n')
                self._send('{} OK CAPABILITY
completed\r\n'.format(tag).encode('ASCII'))

        with self.reaped_server(BadNewlineHandler) as server:
            self.assertRaises(imaplib.IMAP4.abort,
                              self.imap_class, *server.server_address)

Which silently misreads the CAPABILITY response as including "AUT" and
not "AUTH". It would be a perversely broken server, but I think this
test case demonstrates why an explicit check and exception should be
thrown always.
History
Date User Action Args
2009-12-09 19:49:13scott.dialsetrecipients: + scott.dial, barry, rhettinger, ncoghlan, janssen, kevinwatters, benjamin.peterson, r.david.murray, rmore, rtucker
2009-12-09 19:49:13scott.dialsetmessageid: <1260388153.68.0.204484005046.issue5949@psf.upfronthosting.co.za>
2009-12-09 19:49:12scott.diallinkissue5949 messages
2009-12-09 19:49:12scott.dialcreate