bkaankose / Wino-Mail

Built-in Mail & Calendars app clone for Windows.
https://www.winomail.app/
GNU General Public License v3.0
699 stars 35 forks source link

[Bug] Subject and other headers sometimes aren't in the right encoding #441

Open chenseanxy opened 2 days ago

chenseanxy commented 2 days ago

Describe the bug

Subjects, sender names, and preview text are not in the right encoding before being saved to the database, particularly when MIME is in a weird encoding like gbk. This would mean these texts are displayed in the wrong format in the mail list, notifications being sent in the same wrong encoding too, and also these emails won't be searchable

However, the mail rendering page does display these texts without problems.

Also reported by @loshine, #317 @dartraiden

Tested on Windows 10 21H2 and Windows 11 23H2 & 24H2

Expected behavior Encoding should be followed, but this should be MimeKit's job?!

Sample header: Subject: =?GBK?B?seDC67LiytQ=?=

Screenshots

image

Additional context I did a bit of digging, but it seems Wino basically offloads all the parsing to MimeKit and isn't doing anything particularly special after getting a parsed MimeMessage.

Only difference between database entries and rendered mail: MIME for the database is directly parsed when returned from GetMessagesAsync, and MIME for rendered mail is parsed when loaded from file with LoadAsync. Maybe these two have different default options for parser? Needs further investigation

MailCopy: https://github.com/bkaankose/Wino-Mail/blob/5258ae4b34a90cbefd0e04fe30c3870d7a23dbfd/Wino.Core/Synchronizers/ImapSynchronizer.cs#L398-L399

Rendered mail: https://github.com/bkaankose/Wino-Mail/blob/5258ae4b34a90cbefd0e04fe30c3870d7a23dbfd/Wino.Core/Services/MimeFileService.cs#L87-L95

chenseanxy commented 2 days ago

Should have done five minutes of search tbh... Already reported in #317, but not necessarily closing this because I'm too lazy to copy things over lmao