Fix base64-encoded HTML email bodies not rendering; v1.1.18
Inbound emails from some clients (Outlook, mobile) send htmlBody as base64. Decode it on the server before storing (future emails) and on the client before passing to the iframe srcDoc (existing stored emails). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+6
-1
@@ -82,6 +82,11 @@ function formatDate(value: string | null | undefined): string {
|
||||
return Number.isNaN(d.getTime()) ? '—' : d.toLocaleString()
|
||||
}
|
||||
|
||||
function decodeHtmlBody(raw: string): string {
|
||||
if (!raw || raw.trimStart().startsWith('<')) return raw
|
||||
try { return atob(raw.replace(/\s+/g, '')) } catch { return raw }
|
||||
}
|
||||
|
||||
function formatShortDate(value: string | null | undefined): string {
|
||||
if (!value) return '—'
|
||||
const d = new Date(value)
|
||||
@@ -671,7 +676,7 @@ function EmailClient({ onLogout }: { onLogout: () => void }) {
|
||||
<div className="em-detail-body">
|
||||
{selected.htmlBody ? (
|
||||
<iframe
|
||||
srcDoc={selected.htmlBody}
|
||||
srcDoc={decodeHtmlBody(selected.htmlBody!)}
|
||||
sandbox="allow-same-origin"
|
||||
className="em-detail-iframe"
|
||||
onLoad={e => {
|
||||
|
||||
Reference in New Issue
Block a user