You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some attachments give the following error:
File "C:\Users\adminns\AppData\Roaming\Python\Python310\site-packages\imbox\messages.py", line 55, in _fetch_email_list yield uid, self._fetch_email(uid)
File "C:\Users\adminns\AppData\Roaming\Python\Python310\site-packages\imbox\messages.py", line 42, in _fetch_email return fetch_email_by_uid(uid=uid,
File "C:\Users\adminns\AppData\Roaming\Python\Python310\site-packages\imbox\parser.py", line 157, in fetch_email_by_uid email_object = parse_email(raw_email, policy=parser_policy)
File "C:\Users\adminns\AppData\Roaming\Python\Python310\site-packages\imbox\parser.py", line 214, in parse_email attachment = parse_attachment(part)
File "C:\Users\adminns\AppData\Roaming\Python\Python310\site-packages\imbox\parser.py", line 124, in parse_attachment filename_parts.insert(int(s_name[1]),value[1:-1] if value.startswith('"') else value) ValueError: invalid literal for int() with base 10:
An example of value of var "param" in line 114 of file "parser" is: "filename*=iso-8859-1''PALLETWAYS_Renova%E7aoISO_0212.docx".
So var "s_name" as value ['filename', ''] and it breaks in line 122 in: ...int(s_name[1]) because s_name[1] is ''....
What I did was test if s_name[1] is '' and encode the file name if necessary, replacing line 122 with:
if s_name[1] != '':
filename_parts.insert(int(s_name[1]),value[1:-1] if value.startswith('"') else value)
elif "''" in value:
encoding, encoded_filename = value.split("''", 1)
filename_parts.insert(0, urllib.parse.unquote(encoded_filename, encoding))
else:
filename_parts.insert(0,value[1:-1] if value.startswith('"') else value)
Don't forget to include urllib.
Best regards,
The text was updated successfully, but these errors were encountered:
Some attachments give the following error:
File "C:\Users\adminns\AppData\Roaming\Python\Python310\site-packages\imbox\messages.py", line 55, in _fetch_email_list yield uid, self._fetch_email(uid)
File "C:\Users\adminns\AppData\Roaming\Python\Python310\site-packages\imbox\messages.py", line 42, in _fetch_email return fetch_email_by_uid(uid=uid,
File "C:\Users\adminns\AppData\Roaming\Python\Python310\site-packages\imbox\parser.py", line 157, in fetch_email_by_uid email_object = parse_email(raw_email, policy=parser_policy)
File "C:\Users\adminns\AppData\Roaming\Python\Python310\site-packages\imbox\parser.py", line 214, in parse_email attachment = parse_attachment(part)
File "C:\Users\adminns\AppData\Roaming\Python\Python310\site-packages\imbox\parser.py", line 124, in parse_attachment filename_parts.insert(int(s_name[1]),value[1:-1] if value.startswith('"') else value) ValueError: invalid literal for int() with base 10:
An example of value of var "param" in line 114 of file "parser" is: "filename*=iso-8859-1''PALLETWAYS_Renova%E7aoISO_0212.docx".
So var "s_name" as value ['filename', ''] and it breaks in line 122 in: ...int(s_name[1]) because s_name[1] is ''....
What I did was test if s_name[1] is '' and encode the file name if necessary, replacing line 122 with:
if s_name[1] != '':
filename_parts.insert(int(s_name[1]),value[1:-1] if value.startswith('"') else value)
elif "''" in value:
encoding, encoded_filename = value.split("''", 1)
filename_parts.insert(0, urllib.parse.unquote(encoded_filename, encoding))
else:
filename_parts.insert(0,value[1:-1] if value.startswith('"') else value)
Don't forget to include urllib.
Best regards,
The text was updated successfully, but these errors were encountered: