@@ -144,20 +144,45 @@ export class MailParser {
144144 */
145145 private static sanitizeHtml ( html : string ) : string {
146146 return MailParser . purify . sanitize ( html , {
147- ALLOWED_TAGS : [
148- 'p' , 'br' , 'strong' , 'em' , 'u' , 's' , 'a' , 'img' ,
149- 'h1' , 'h2' , 'h3' , 'h4' , 'h5' , 'h6' ,
150- 'ul' , 'ol' , 'li' , 'blockquote' , 'pre' , 'code' ,
151- 'table' , 'thead' , 'tbody' , 'tr' , 'th' , 'td' ,
152- 'div' , 'span' , 'hr'
153- ] ,
154- ALLOWED_ATTR : [
155- 'href' , 'src' , 'alt' , 'title' , 'class' , 'id' ,
156- 'width' , 'height' , 'style' , 'target' , 'rel'
157- ] ,
147+ USE_PROFILES : { html : true } ,
148+ // Allow only safe tags for email rendering
149+ // ALLOWED_TAGS: [
150+ // // Structure
151+ // 'div', 'span', 'p', 'br', 'hr',
152+ // // Headings
153+ // 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
154+ // // Text formatting
155+ // 'b', 'i', 'u', 'em', 'strong', 'small', 'sub', 'sup', 's', 'strike', 'del', 'ins', 'mark',
156+ // // Lists
157+ // 'ul', 'ol', 'li', 'dl', 'dt', 'dd',
158+ // // Links & images
159+ // 'a', 'img',
160+ // // Tables
161+ // 'table', 'thead', 'tbody', 'tfoot', 'tr', 'th', 'td', 'caption', 'colgroup', 'col',
162+ // // Semantic
163+ // 'blockquote', 'pre', 'code', 'abbr', 'address', 'cite', 'q',
164+ // // Layout (common in email HTML)
165+ // 'center', 'font',
166+ // ],
167+ // ALLOWED_ATTR: [
168+ // 'href', 'src', 'alt', 'title', 'width', 'height',
169+ // 'style', 'class', 'id', 'dir', 'lang',
170+ // 'colspan', 'rowspan', 'cellpadding', 'cellspacing', 'border',
171+ // 'align', 'valign', 'bgcolor', 'color', 'size', 'face',
172+ // 'target', 'rel',
173+ // ],
174+
175+ // Forbid dangerous URI schemes
158176 ALLOWED_URI_REGEXP : / ^ (?: (?: (?: f | h t ) t p s ? | m a i l t o | t e l | c a l l t o | c i d | x m p p | d a t a ) : | [ ^ a - z ] | [ a - z + . \- ] + (?: [ ^ a - z + . \- : ] | $ ) ) / i,
177+
178+ // Forbid forms, iframes, scripts etc.
179+ FORBID_TAGS : [ 'script' , 'iframe' , 'object' , 'embed' , 'form' , 'input' , 'textarea' , 'select' , 'button' , 'meta' , 'link' , 'base' ] ,
180+ FORBID_ATTR : [ 'onerror' , 'onload' , 'onclick' , 'onmouseover' , 'onfocus' , 'onblur' , 'onsubmit' , 'onreset' , 'onselect' , 'onchange' , 'onkeydown' , 'onkeypress' , 'onkeyup' ] ,
181+
182+ // Remove contents of dangerous elements (not just the tags)
159183 KEEP_CONTENT : true ,
160- RETURN_TRUSTED_TYPE : false ,
184+ // Allow ARIA attributes
185+ ALLOW_ARIA_ATTR : true ,
161186 } ) ;
162187 }
163188
0 commit comments