Show
Ignore:
Timestamp:
09/10/10 20:27:56 (21 months ago)
Author:
Menno Smits <menno@…>
Branch:
default
Children:
172:6317981e42a5, 179:970ef3c54d53
Message:

Tokens shouldn't necessarily terminate after a "]"

This was breaking partial fetch response parsing.

Location:
imapclient
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • imapclient/response_lexer.py

    r169 r171  
    8282                if nextchar in wordchars: 
    8383                    token += nextchar 
     84                elif nextchar == '[': 
     85                    token += nextchar + read_until(stream_i, ']', escape=False) 
    8486                else: 
    85                     if nextchar == '[': 
    86                         yield token + nextchar + read_until(stream_i, ']', escape=False) 
    87                     elif nextchar in whitespace: 
     87                    if nextchar in whitespace: 
    8888                        yield token 
    8989                    elif nextchar == '"': 
  • imapclient/test/test_response_parser.py

    r170 r171  
    140140        self._test('foo[bar rrr]', 'foo[bar rrr]') 
    141141        self._test('"foo[bar rrr]"', 'foo[bar rrr]') 
    142         self._test('[foo bar]', '[foo bar]')  # Square brackets at start 
     142        self._test('[foo bar]def', '[foo bar]def') 
    143143        self._test('(foo [bar rrr])', ('foo', '[bar rrr]')) 
    144144        self._test('(foo foo[bar rrr])', ('foo', 'foo[bar rrr]')) 
     
    265265            { 31710: {'BODY[HEADER.FIELDS (FROM SUBJECT)]': header_text, 
    266266                      'SEQ': 123}}) 
    267                
     267 
     268 
     269    def test_partial_fetch(self): 
     270        body = '01234567890123456789' 
     271        self.assertEquals(parse_fetch_response( 
     272            [('123 (UID 367 BODY[]<0> {20}', body), ')']), 
     273            { 367: {'BODY[]<0>': body, 
     274                    'SEQ': 123}}) 
     275                     
    268276 
    269277    def test_INTERNALDATE(self):