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

#21: High ascii bytes in folder names can break folder handling

Don't allow characters in str based folder names that can't be
converted to unicode without knowing the encoding. The idea is that
IMAPClient's user should convert to unicode themselves.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • imapclient/imap_utf7.py

    r62 r147  
    2424 
    2525 
     26class FolderNameError(ValueError): 
     27    pass 
     28 
     29 
    2630def encode(s): 
     31    if isinstance(s, str) and sum(n for n in (ord(c) for c in s) if n > 127): 
     32        raise FolderNameError("%r contains characters not valid in a str folder name. " 
     33                              "Convert to unicode first?" % s) 
     34 
    2735    r = [] 
    2836    _in = []