fix imap4-utf-7 decoding errors
>>> import offlineimap.imaputil >>> b'&g0l6Pw-'.decode('imap4-utf-7') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/ldata/src/offlineimap3/offlineimap/imaputil.py", line 406, in utf7m_decode for c in binary.decode(): AttributeError: 'memoryview' object has no attribute 'decode' Signed-off-by: lilydjwg <lilydjwg@gmail.com>
This commit is contained in:
parent
e64c254072
commit
90be450f4d
@ -403,19 +403,19 @@ def modified_unbase64(s):
|
|||||||
def utf7m_decode(binary: bytes) -> Tuple[str, int]:
|
def utf7m_decode(binary: bytes) -> Tuple[str, int]:
|
||||||
r = []
|
r = []
|
||||||
decode = []
|
decode = []
|
||||||
for c in binary.decode():
|
for c in binary:
|
||||||
if c == '&' and not decode:
|
if c == ord('&') and not decode:
|
||||||
decode.append('&')
|
decode.append('&')
|
||||||
elif c == '-' and decode:
|
elif c == ord('-') and decode:
|
||||||
if len(decode) == 1:
|
if len(decode) == 1:
|
||||||
r.append('&')
|
r.append('&')
|
||||||
else:
|
else:
|
||||||
r.append(modified_unbase64(''.join(decode[1:])))
|
r.append(modified_unbase64(''.join(decode[1:])))
|
||||||
decode = []
|
decode = []
|
||||||
elif decode:
|
elif decode:
|
||||||
decode.append(c)
|
decode.append(chr(c))
|
||||||
else:
|
else:
|
||||||
r.append(c)
|
r.append(chr(c))
|
||||||
|
|
||||||
if decode:
|
if decode:
|
||||||
r.append(modified_unbase64(''.join(decode[1:])))
|
r.append(modified_unbase64(''.join(decode[1:])))
|
||||||
|
Loading…
Reference in New Issue
Block a user