From d9e848d3f459d9c7bb2bd0394ea9a9f798c4265f Mon Sep 17 00:00:00 2001 From: Lyz Coote Date: Thu, 5 Feb 2026 15:26:52 +0100 Subject: [PATCH] feat: add UTF-8 conversion for email body and enhance MailViewer processing --- app.go | 17 ++++++ config.ini | 2 +- frontend/src/lib/components/MailViewer.svelte | 53 ++++++++++++++++--- frontend/src/lib/utils.ts | 16 +++++- installer/installer.iss | 2 +- 5 files changed, 79 insertions(+), 11 deletions(-) diff --git a/app.go b/app.go index 13d23ac..f5c82a7 100644 --- a/app.go +++ b/app.go @@ -10,8 +10,11 @@ import ( "strings" "sync" "time" + "unicode/utf8" "golang.org/x/sys/windows/registry" + "golang.org/x/text/encoding/charmap" + "golang.org/x/text/transform" "emly/backend/utils" internal "emly/backend/utils/mail" @@ -517,3 +520,17 @@ func (a *App) IsDebuggerRunning() bool { } return utils.IsDebugged() } + +func (a *App) ConvertToUTF8(s string) string { + if utf8.ValidString(s) { + return s + } + + // If invalid UTF-8, assume Windows-1252 (superset of ISO-8859-1) + decoder := charmap.Windows1252.NewDecoder() + decoded, _, err := transform.String(decoder, s) + if err != nil { + return s // Return as-is if decoding fails + } + return decoded +} diff --git a/config.ini b/config.ini index 5bea096..e03a372 100644 --- a/config.ini +++ b/config.ini @@ -1,6 +1,6 @@ [EMLy] SDK_DECODER_SEMVER="1.3.1" SDK_DECODER_RELEASE_CHANNEL="beta" -GUI_SEMVER="1.3.0" +GUI_SEMVER="1.3.1" GUI_RELEASE_CHANNEL="beta" LANGUAGE="it" \ No newline at end of file diff --git a/frontend/src/lib/components/MailViewer.svelte b/frontend/src/lib/components/MailViewer.svelte index 6114349..2bc34f6 100644 --- a/frontend/src/lib/components/MailViewer.svelte +++ b/frontend/src/lib/components/MailViewer.svelte @@ -1,6 +1,6 @@