Changeset 96:6f290ccd5e5b

Show
Ignore:
Timestamp:
05/01/10 13:42:35 (2 years ago)
Author:
Menno Smits <menno@…>
Branch:
default
Message:

Fixed problem when literal is followed by a non-literal (#33)

This problem manifested itself with GMail's IMAP. Patch based on what
Fergal sent in with the bug report.

Files:
3 modified

Legend:

Unmodified
Added
Removed
  • THANKS

    r70 r96  
    2323Brian Jackson 
    2424Neil Martinsen-Burrell 
     25Fergal (fergal _AT_ esatclear.ie) 
    2526 
    2627 
  • imapclient/imapclient.py

    r93 r96  
    599599 
    600600        data = data.lstrip() 
     601        msgid = None 
    601602        if data[0].isdigit(): 
    602603            # Get message ID 
     
    606607            assert data.startswith('('), data 
    607608            data = data[1:] 
    608             if data.endswith(')'): 
    609                 data = data[:-1] 
    610  
    611         else: 
    612             msgid = None 
     609 
     610        if data.endswith(')'): 
     611            data = data[:-1] 
    613612 
    614613        for name, item in FetchTokeniser().process_pairs(data): 
  • imapclient/test/test_FetchParser.py

    r90 r96  
    180180 
    181181    def testMultiTypesWithLiteral(self): 
    182         self._parse_test( 
    183             [ 
    184                 ('1 (INTERNALDATE " 9-Feb-2007 17:08:08 +0100" RFC822 {21}', 
    185                       'Subject: test\r\n\r\nbody'), 
    186                 ')' 
    187                 ], 
    188             {1: { 
    189                     'INTERNALDATE': datetime_to_native(datetime.datetime(2007, 2, 9, 
    190                                                                          17, 8, 8, 0, 
    191                                                                          FixedOffset(60))), 
    192                     'RFC822': 'Subject: test\r\n\r\nbody', 
     182        expected = {1: {'INTERNALDATE': datetime_to_native(datetime.datetime(2007, 2, 9, 
     183                                                                             17, 8, 8, 0, 
     184                                                                             FixedOffset(60))), 
     185                        'RFC822': 'Subject: test\r\n\r\nbody'} 
    193186                    } 
    194                 } 
    195             ) 
     187        self._parse_test([('1 (INTERNALDATE " 9-Feb-2007 17:08:08 +0100" RFC822 {21}', 
     188                           'Subject: test\r\n\r\nbody'), ')'], 
     189                         expected) 
     190 
     191        # Also test where there literal comes back first 
     192        self._parse_test([('1 (RFC822 {21}', 'Subject: test\r\n\r\nbody'), 
     193                           'INTERNALDATE " 9-Feb-2007 17:08:08 +0100")'], 
     194                           expected) 
    196195 
    197196    def testLiteralsWithSections(self):