From eb8bc7a4ec1b5ca19a4b50040d96eb8b1024fd34 Mon Sep 17 00:00:00 2001 From: Nikolaus Schulz Date: Sun, 26 Sep 2010 20:17:53 +0200 Subject: IMAP: correctly handle IMAP `literal' and unquoted `astring' in LIST reply The LIST reply handling in imap_find_mailboxes() was buggy in several ways. It expected a non-NIL hierarchy delimiter, and it assumed that the mailbox name in a LIST reply is always quoted; but it can be an astring, a quoted string, or a literal (see RFC 3501 for the definitions of these tokens). These variants should now all be interpreted correctly. In addition, quoted mailbox names are now handled more strictly to the letter of the RFC; this only affects mailbox names containing a " or a backslash, though. --- test_archivemail | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test_archivemail') diff --git a/test_archivemail b/test_archivemail index c49508f..6fff170 100755 --- a/test_archivemail +++ b/test_archivemail @@ -617,6 +617,26 @@ class TestParseIMAPUrl(unittest.TestCase): archivemail.options.verbose = False archivemail.options.pwfile = None +########## quoting and un-quoting of IMAP strings ########## + +class TestIMAPQuoting(unittest.TestCase): + stringlist = ( + ('{braces} and space', '"{braces} and space"'), + ('\\backslash', '"\\\\backslash"'), + ('with "quotes" inbetween', '"with \\"quotes\\" inbetween"'), + ('ending with "quotes"', '"ending with \\"quotes\\""'), + ('\\"backslash before quote', '"\\\\\\"backslash before quote"') + ) + + def testQuote(self): + for unquoted, quoted in self.stringlist: + self.assertEqual(archivemail.imap_quote(unquoted), quoted) + + def testUnquote(self): + for unquoted, quoted in self.stringlist: + self.assertEqual(unquoted, archivemail.imap_unquote(quoted)) + + ########## acceptance testing ########### class TestArchive(TestCaseInTempdir): -- cgit v1.2.3