Fix garbled ticket text from HTML emails (Outlook VML/entities)

extractBody() used a naive tag-stripping regex as a fallback, which
strips <style> tags but leaves their CSS content behind as visible
text, and never decodes HTML entities. Outlook's VML style block
(v\:* {behavior:url(#default#VML);} ...) and &nbsp;/&laquo; entities
were leaking straight into ticket bodies as a result.

Now uses html-to-text (already a transitive dep via mailparser,
promoted to direct) to convert the HTML part whenever present, which
correctly drops <head>/<style> content and decodes entities. Also
stopped trusting parsed.text unconditionally — some senders' plain-text
alternative isn't actually clean, so HTML is now the primary source
whenever available.
This commit is contained in:
ogrechko committed 2026-08-10 13:53:19 +00:00
1 parent 8844323cad
commit 87cf045715
4 files changed
+20 -2

No files matched your search

+1
View File
@@ -12,6 +12,7 @@
"better-sqlite3": "^12.11.1",
"drizzle-orm": "^0.45.2",
"framer-motion": "^12.4.7",
"html-to-text": "^10.0.0",
"imapflow": "^1.5.0",
"ldapjs": "^3.0.7",
"lucide-react": "^0.545.0",