From c509cb4edec50709a0dd8bf24b696a63488d6e7d Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Mon, 9 Sep 2013 09:29:19 +0200 Subject: [PATCH] Support only integers for this option. fixes #478 --- .../extensions/webmail/static/webmail/js/webmail.js | 2 +- modoboa/lib/emailutils.py | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/modoboa/extensions/webmail/static/webmail/js/webmail.js b/modoboa/extensions/webmail/static/webmail/js/webmail.js index 8cea472b2..c9c745bea 100644 --- a/modoboa/extensions/webmail/static/webmail/js/webmail.js +++ b/modoboa/extensions/webmail/static/webmail/js/webmail.js @@ -83,7 +83,7 @@ Webmail.prototype = { $(document).on("click", "a[name=forward]", $.proxy(this.reply_loader, this)); $(document).on("click", "a[name=delete]", $.proxy(this.delete_message, this)); $(document).on("click", "a[name=activate_links]", $.proxy(function(e) { this.display_mode(e, "1"); }, this)); - $(document).on("click", "a[name=disable_links]", $.proxy(function(e) { this.disable_mode(e, "0"); }, this)); + $(document).on("click", "a[name=disable_links]", $.proxy(function(e) { this.display_mode(e, "0"); }, this)); $(document).on("click", "a[name=sendmail]", $.proxy(this.sendmail, this)); diff --git a/modoboa/lib/emailutils.py b/modoboa/lib/emailutils.py index bc58ea1b3..66fe831c1 100644 --- a/modoboa/lib/emailutils.py +++ b/modoboa/lib/emailutils.py @@ -23,7 +23,7 @@ class EmailAddress(object): return self.fulladdress class Email(object): - def __init__(self, msg, mformat="plain", dformat="plain", links="0"): + def __init__(self, msg, mformat="plain", dformat="plain", links=0): self.attached_map = {} self.contents = {"html" : "", "plain" : ""} self.headers = [] @@ -78,7 +78,7 @@ class Email(object): sometimes, messages embark inline images, which means they must be displayed and not attached. """ - if self.dformat == "html" and self.links != "0" \ + if self.dformat == "html" and self.links \ and msg.has_key("Content-Disposition"): if msg["Content-Disposition"].startswith("inline"): cid = None @@ -167,9 +167,9 @@ class Email(object): def viewmail_html(self, content, **kwargs): if content is None or content == "": return "" - links = kwargs.has_key("links") and kwargs["links"] or "0" - html = lxml.html.fromstring(content) - if links == "0": + links = kwargs.get("links", 0) + html = lxml.html.fromstring(content) + if not links: html.rewrite_links(lambda x: None) else: html.rewrite_links(self.map_cid) @@ -179,7 +179,6 @@ class Email(object): else: body = lxml.html.tostring(body) body = re.sub("<(/?)body", lambda m: "<%sdiv" % m.group(1), body) - body = Template(body).render(Context({})) return body def split_mailbox(mailbox):