[FIX] mail tools: html_sanitize must keep useful styles from mass mailing

Issue: The clean removes too many tags so emails sent do not resemble the
preview.

opw-1841138
opw-1841105
This commit is contained in:
Christophe Matthieu
2018-05-07 15:34:40 +02:00
parent cf1b1b6e2c
commit b8006bfb1c
+12 -3
View File
@@ -42,14 +42,23 @@ class _Cleaner(clean.Cleaner):
_style_re = re.compile('''([\w-]+)\s*:\s*((?:[^;"']|"[^"]*"|'[^']*')+)''')
_style_whitelist = [
'font-size', 'font-family', 'background-color', 'color', 'text-align',
'font-size', 'font-family', 'font-weight',
'background-color', 'color', 'float', 'vertical-align',
'line-height', 'text-align', 'text-decoration',
'padding', 'padding-top', 'padding-left', 'padding-bottom', 'padding-right',
'margin', 'margin-top', 'margin-left', 'margin-bottom', 'margin-right'
'margin', 'margin-top', 'margin-left', 'margin-bottom', 'margin-right',
# box model
'border', 'border-color', 'border-radius', 'height', 'margin', 'padding', 'width', 'max-width', 'min-width',
'border', 'border-color', 'border-style', 'border-radius', 'border-width',
'height', 'margin', 'padding', 'width', 'max-width', 'min-width',
# tables
'border-collapse', 'border-spacing', 'caption-side', 'empty-cells', 'table-layout']
_style_whitelist.extend(
['border-%s-%s' % (position, attribute)
for position in ['top', 'bottom', 'left', 'right']
for attribute in ('style', 'color', 'width', 'left-radius', 'right-radius')]
)
strip_classes = False
sanitize_style = False