fix: convert non-UTF-8 email body charset to UTF-8#324
Merged
butschster merged 1 commit intomasterfrom Mar 31, 2026
Merged
Conversation
Email bodies arriving in charsets like windows-1250, iso-8859-2, etc. were stored as raw bytes and displayed as garbled text (�). Added convertToUTF8() using golang.org/x/text to transcode body content based on the charset parameter from Content-Type headers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds charset-to-UTF-8 conversion for SMTP email bodies. Non-UTF-8 charsets (e.g.
windows-1250,iso-8859-2) are now transcoded before storage.Why
Emails with non-UTF-8 Content-Type charset (common for Czech, German, and other languages) were displayed as garbled text (
��) in both the HTML preview and raw text tabs.How
convertToUTF8()function usinggolang.org/x/text/encoding/ianaindexto transcode body bytes based on thecharsetparameter from Content-TypeTesting
TestConvertToUTF8— 5 cases: utf-8 passthrough, empty charset, windows-1250 Czech, iso-8859-1 Latin, unknown charsetTestParseEmail_CharsetConversion— 3 integration cases: single-part text, single-part html, multipart with charsetgo test ./modules/smtp/— all pass