got-your-back icon indicating copy to clipboard operation
got-your-back copied to clipboard

--cleanup on From headers with utf-8 characters

Open dantasfiles opened this issue 3 years ago • 1 comments

Please confirm the following:

  • I have upgraded to the latest GYB release from https://github.com/jay0lee/got-your-back/releases and I still have this issue. v1.55 for Windows
  • I am typing the command as described in the GAM Wiki at https://github.com/jay0lee/got-your-back/wiki Using ./gyb --email [email]@gmail.com --action restore --local-folder GYB-GMail-Backup-[email]@[domain].com --cleanup

Full steps to reproduce the issue: Try to cleanup and restore an email that has utf-8 characters in the From header

Expected outcome (what are you trying to do?): Email is cleaned up and restored

Actual outcome (what errors or bad behavior do you see instead?):

Traceback (most recent call last):
  File "gyb.py", line 2532, in <module>
  File "gyb.py", line 2007, in main
  File "gyb.py", line 1769, in message_hygiene
  File "gyb.py", line 1713, in cleanup_from
  File "email\utils.py", line 215, in parseaddr
  File "email\_parseaddr.py", line 513, in __init__
  File "email\_parseaddr.py", line 256, in getaddrlist
TypeError: object of type 'Header' has no len()
[8912] Failed to execute script 'gyb' due to unhandled exception!

Normally, the line https://github.com/GAM-team/got-your-back/blob/e6f3c7b056a971dec9081d5254aceed941d414af/gyb.py#L1728 will return a string containing the contents of the From header

But if the From header has a utf-8 character (U+00AE in my case), the above line will return an email.header.Header object

Then in line https://github.com/GAM-team/got-your-back/blob/e6f3c7b056a971dec9081d5254aceed941d414af/gyb.py#L1706 parseaddr dies because it's passed an email.header.Header object, not a string.

I'm not even sure if From headers are supposed to have utf-8 characters in them, as this only came up in 3 emails I was restoring that happened to be spam. My workaround was to run the restore operation without the cleanup option for a block of 15 emails (that contained the offending character), then Ctrl-C, and run the restore operation with the cleanup operation on the rest of my emails.

dantasfiles avatar Mar 05 '22 04:03 dantasfiles

I can confirm I am also seeing this issue.

chazy avatar Apr 11 '22 08:04 chazy