mail page fix
This commit is contained in:
parent
d0b59a687e
commit
686288be95
@ -370,14 +370,28 @@ function getReplyBody(email: Email, type: 'reply' | 'reply-all' | 'forward'): st
|
||||
.join('');
|
||||
}
|
||||
|
||||
// Sanitize HTML content
|
||||
// Clean HTML content while preserving formatting
|
||||
content = content
|
||||
.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, '')
|
||||
.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, '')
|
||||
.replace(/<meta[^>]*>/gi, '')
|
||||
.replace(/<link[^>]*>/gi, '')
|
||||
.replace(/<base[^>]*>/gi, '')
|
||||
.replace(/<title[^>]*>[\s\S]*?<\/title>/gi, '')
|
||||
.replace(/<head[^>]*>[\s\S]*?<\/head>/gi, '')
|
||||
.replace(/<body[^>]*>/gi, '')
|
||||
.replace(/<\/body>/gi, '')
|
||||
.replace(/<html[^>]*>/gi, '')
|
||||
.replace(/<\/html>/gi, '');
|
||||
|
||||
// Sanitize HTML content while preserving formatting
|
||||
content = DOMPurify.sanitize(content, {
|
||||
ALLOWED_TAGS: [
|
||||
'p', 'br', 'div', 'span', 'b', 'i', 'u', 'strong', 'em',
|
||||
'blockquote', 'ul', 'ol', 'li', 'a', 'h1', 'h2', 'h3', 'h4',
|
||||
'table', 'thead', 'tbody', 'tr', 'td', 'th'
|
||||
'table', 'thead', 'tbody', 'tr', 'td', 'th', 'pre', 'code'
|
||||
],
|
||||
ALLOWED_ATTR: ['href', 'style', 'class'],
|
||||
ALLOWED_ATTR: ['href', 'style', 'class', 'target'],
|
||||
});
|
||||
|
||||
const date = new Date(email.date).toLocaleString();
|
||||
@ -386,22 +400,22 @@ function getReplyBody(email: Email, type: 'reply' | 'reply-all' | 'forward'): st
|
||||
return `
|
||||
<br/>
|
||||
<br/>
|
||||
<div style="border-left: 2px solid #ccc; padding-left: 1em; margin-left: 0.5em;">
|
||||
<div class="prose max-w-none" style="border-left: 2px solid #ccc; padding-left: 1em; margin-left: 0.5em;">
|
||||
<p><strong>From:</strong> ${email.from}</p>
|
||||
<p><strong>Date:</strong> ${date}</p>
|
||||
<p><strong>Subject:</strong> ${email.subject}</p>
|
||||
<p><strong>To:</strong> ${Array.isArray(email.to) ? email.to.join(', ') : email.to}</p>
|
||||
<br/>
|
||||
${content}
|
||||
<div class="prose max-w-none">${content}</div>
|
||||
</div>
|
||||
`;
|
||||
} else {
|
||||
return `
|
||||
<br/>
|
||||
<br/>
|
||||
<div style="border-left: 2px solid #ccc; padding-left: 1em; margin-left: 0.5em;">
|
||||
<div class="prose max-w-none" style="border-left: 2px solid #ccc; padding-left: 1em; margin-left: 0.5em;">
|
||||
<p>On ${date}, ${email.from} wrote:</p>
|
||||
${content}
|
||||
<div class="prose max-w-none">${content}</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user