mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-11-22 10:34:10 +01:00
whitespace fixes
This commit is contained in:
+18
-17
@@ -179,7 +179,8 @@ class Email(object):
|
||||
if content_type == "text":
|
||||
self._parse_text(part, level=level)
|
||||
else:
|
||||
# I'm a dumb mail parser and treat all non-text parts as attachments
|
||||
# I'm a dumb mail parser and treat all non-text parts as
|
||||
# attachments
|
||||
self._parse_inline_image(part, level=level)
|
||||
|
||||
def _parse_inline_image(self, msg, level=0):
|
||||
@@ -225,13 +226,13 @@ class Email(object):
|
||||
html.rewrite_links(lambda x: None)
|
||||
|
||||
cleaner = Cleaner(
|
||||
scripts=True,
|
||||
javascript=True,
|
||||
links=True,
|
||||
page_structure=True,
|
||||
embedded=True,
|
||||
frames=True,
|
||||
add_nofollow=True)
|
||||
scripts=True,
|
||||
javascript=True,
|
||||
links=True,
|
||||
page_structure=True,
|
||||
embedded=True,
|
||||
frames=True,
|
||||
add_nofollow=True)
|
||||
mail_text = lxml.html.tostring(cleaner.clean_html(html))
|
||||
self.contents["html"] = smart_text(mail_text)
|
||||
|
||||
@@ -289,18 +290,18 @@ def split_local_part(local_part, delimiter=None):
|
||||
# never split these special addresses
|
||||
pass
|
||||
elif (
|
||||
delimiter == "-"
|
||||
and (local_part.startswith("owner-")
|
||||
or local_part.endswith("-request"))
|
||||
delimiter == "-" and
|
||||
(local_part.startswith("owner-") or
|
||||
local_part.endswith("-request"))
|
||||
):
|
||||
# don't split owner-* or *-request if - is the delimiter, they are
|
||||
# special addresses used by mail lists.
|
||||
pass
|
||||
elif (
|
||||
delimiter
|
||||
and delimiter in local_part
|
||||
and local_part[0] != delimiter
|
||||
and local_part[-1] != delimiter
|
||||
delimiter and
|
||||
delimiter in local_part and
|
||||
local_part[0] != delimiter and
|
||||
local_part[-1] != delimiter
|
||||
):
|
||||
local_part, extension = local_part.split(delimiter, 1)
|
||||
|
||||
@@ -341,8 +342,8 @@ def decode(value_bytes, encoding, append_to_error=""):
|
||||
except (TypeError, UnicodeDecodeError) as exc:
|
||||
six.raise_from(
|
||||
InternalError(
|
||||
_("unable to determine encoding of string")
|
||||
+ append_to_error
|
||||
_("unable to determine encoding of string") +
|
||||
append_to_error
|
||||
),
|
||||
exc
|
||||
)
|
||||
|
||||
@@ -35,7 +35,7 @@ def alert(msg, typ):
|
||||
t = Template("""<div class="alert alert-{{ type }}" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
{{ msg }}
|
||||
</div>""")
|
||||
</div>""") # NOQA:E501
|
||||
return t.render(Context({"type": typ, "msg": msg}))
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class="{{ mdclass }}{% if link.class %} {{ link.class }}{% endif %}"
|
||||
{% for attr, value in link.extra_attributes.items %} {{ attr }}="{{ value }}"{% endfor %}
|
||||
>
|
||||
{% if link.img %}<i class="{{ link.img }}"></i>{% endif %}
|
||||
{{ link.label }}</a>""")
|
||||
{{ link.label }}</a>""") # NOQA:E501
|
||||
return t.render(Context({"link": linkdef, "mdclass": mdclass}))
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ def render_tags(tags):
|
||||
<a href="#" class="filter {{ tag.type }}" name="{{ tag.name }}">{{ tag.label }}</a>
|
||||
</span>
|
||||
{% endfor %}
|
||||
""")
|
||||
""") # NOQA:E501
|
||||
return t.render(Context({"tags": tags}))
|
||||
|
||||
|
||||
|
||||
@@ -65,9 +65,10 @@ class EmailTests(SimpleTestCase):
|
||||
EmailTestImplementation("text_plain", links="0")
|
||||
|
||||
ex_message = cm.exception.messages
|
||||
self.assertEqual(ex_message,
|
||||
"links == \"0\" is not valid, did you mean True or "
|
||||
"False?")
|
||||
self.assertEqual(
|
||||
ex_message,
|
||||
"links == \"0\" is not valid, did you mean True or False?"
|
||||
)
|
||||
|
||||
def test_links_value_for_webmail(self):
|
||||
"""modoboa-webmail sets links = 0 or 1
|
||||
@@ -106,7 +107,7 @@ class EmailTests(SimpleTestCase):
|
||||
self._test_email("multipart", dformat="html", links=True)
|
||||
|
||||
def test_email_multipart_without_links(self):
|
||||
"""display the text/html part of a multipart message with links removed"""
|
||||
"""display the text/html part of a multipart message without links"""
|
||||
self._test_email("multipart", dformat="html", links=False)
|
||||
|
||||
|
||||
|
||||
@@ -49,7 +49,8 @@ class UTF8EmailValidator(EmailValidator):
|
||||
# dot-atom
|
||||
r"^[" + ascii_set + ul + r"]+(\.[" + ascii_set + ul + r"]+)*\Z"
|
||||
# quoted-string
|
||||
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"\Z)'
|
||||
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|'
|
||||
r'\\[\001-\011\013\014\016-\177])*"\Z)'
|
||||
)
|
||||
user_regex = re.compile(r"(" + user_regex_raw, re.IGNORECASE)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user