rgladwell / imap-upload

Python script for uploading a local mbox file to IMAP4 server.
Other
130 stars 30 forks source link

Subject formatting fix #53

Closed adriangibanelbtactic closed 2 years ago

adriangibanelbtactic commented 2 years ago

Now the subject has always the 30 character length size with much less code.

This pull request builds on https://github.com/rgladwell/imap-upload/pull/52 so it's meant to be approved once the former pull request has been merged into upstream.

adriangibanelbtactic commented 2 years ago

I brought this fix because some of the subjects were not padded properly.

Also using just a line as hinted by https://stackoverflow.com/a/43939328 was a good thing. No longer was needed to use three extra functions.

Now I see that some of the subjects are still not padded properly, probably because of chinese characters.

I'm currently checking: https://stackoverflow.com/questions/4622357/how-to-control-padding-of-unicode-string-containing-east-asia-characters and https://pythonhosted.org/kitchen/api-text-display.html to see if it's a better approach.

adriangibanelbtactic commented 2 years ago

I brought this fix because some of the subjects were not padded properly.

Also using just a line as hinted by https://stackoverflow.com/a/43939328 was a good thing. No longer was needed to use three extra functions.

Now I see that some of the subjects are still not padded properly, probably because of chinese characters.

I'm currently checking: https://stackoverflow.com/questions/4622357/how-to-control-padding-of-unicode-string-containing-east-asia-characters and https://pythonhosted.org/kitchen/api-text-display.html to see if it's a better approach.

It seems that my problem is specifically related to non printable characters. Those non printable characters messed up with the string length (string length versus the length you get in the screen once you print it).

Removing control characters from the subject line is probably the way to go:

https://stackoverflow.com/a/93029

adriangibanelbtactic commented 2 years ago

Ok, I am now satisfied with the last fix.

You can review this pull request.

Thank you.

rgladwell commented 2 years ago

Thanks.