[FIX] tools: mail transcoding css space consistent
The transcoding of a mail (transforming CSS into inline styles on the
element nodes of the mail) used the form:
property:value;
So when a mail is saved, it would be eg. with `style="property:value;"`
and when it is being edited "property:value" is removed if available via
CSS stylesheet given the structure.
But the sanitize_style (introduced in bfe7aafa7) adds an espace before
the value (which is more pretty but was probably not choosen in
transcoding to decrease size of mail):
property: value;
so the inline style would not be removed when editing possibly causing
conflict with the editor.
With this commit, the sanitize_style doesn't add a space. It could have
been changed in transcoding but the code is already rather slow and we
don't want to use a regex replace or two string replace instead of the
current one string replace.
opw-1841107
This commit is contained in:
@@ -115,7 +115,7 @@ class TestSanitizer(unittest.TestCase):
|
||||
test_data = [
|
||||
(
|
||||
'<span style="position: fixed; top: 0px; left: 50px; width: 40%; height: 50%; background-color: red;">Coin coin </span>',
|
||||
['background-color: red', 'Coin coin'],
|
||||
['background-color:red', 'Coin coin'],
|
||||
['position', 'top', 'left']
|
||||
), (
|
||||
"""<div style='before: "Email Address; coincoin cheval: lapin";
|
||||
@@ -123,7 +123,7 @@ class TestSanitizer(unittest.TestCase):
|
||||
|
||||
this; means: anything ?#ùµ"
|
||||
; some-property: 2px; top: 3'>youplaboum</div>""",
|
||||
['font-size: 30px', 'youplaboum'],
|
||||
['font-size:30px', 'youplaboum'],
|
||||
['some-property', 'top', 'cheval']
|
||||
), (
|
||||
'<span style="width">Coincoin</span>',
|
||||
|
||||
@@ -510,7 +510,7 @@ REMOVE_CLASS = """
|
||||
</div>
|
||||
"""
|
||||
REMOVE_CLASS_IN = [
|
||||
'<div style="color: #000000; font-size: 12pt; font-family: \'Times New Roman\'">',
|
||||
'<div style="color:#000000; font-size:12pt; font-family:\'Times New Roman\'">',
|
||||
'An error occured in a modal and I will send you back the html to try opening one on your end']
|
||||
REMOVE_CLASS_OUT = [
|
||||
'<div class="modal-backdrop in">',
|
||||
|
||||
+1
-1
@@ -154,7 +154,7 @@ class _Cleaner(clean.Cleaner):
|
||||
if style[0].lower() in self._style_whitelist:
|
||||
valid_styles[style[0].lower()] = style[1]
|
||||
if valid_styles:
|
||||
el.attrib['style'] = '; '.join('%s: %s' % (key, val) for (key, val) in valid_styles.iteritems())
|
||||
el.attrib['style'] = '; '.join('%s:%s' % (key, val) for (key, val) in valid_styles.iteritems())
|
||||
else:
|
||||
del el.attrib['style']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user