Merge pull request #114 from lilydjwg/master
fix imap4-utf-7 decoding errors
This commit is contained in:
commit
6cec099e70
@ -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