Skip to content

Commit

Permalink
Fixed issue when replying to mail with quoted From.
Browse files Browse the repository at this point in the history
fix #199
  • Loading branch information
tonioo committed Apr 2, 2021
1 parent 1ef390f commit 99e5990
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions modoboa_webmail/lib/imapemail.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from modoboa.lib import u2u_decode
from modoboa.lib.email_utils import Email, EmailAddress

from .. import constants
from . import imapheader
from .attachments import get_storage_path
from .imaputils import (
Expand Down Expand Up @@ -96,7 +95,11 @@ def get_header(self, msg, hdrname, **kwargs):
We also try to decode the default value.
"""
hdrvalue = super(ImapEmail, self).get_header(msg, hdrname)
hdrvalue = super().get_header(msg, hdrname)
if hdrname in ["From", "Reply-To"]:
# Store a raw copy for further use
setattr(self, "original_{}".format(hdrname.replace("-", "")),
hdrvalue)
if not hdrvalue:
return ""
try:
Expand Down Expand Up @@ -275,17 +278,17 @@ class ReplyModifier(Modifier):
]

def __init__(self, *args, **kwargs):
super(ReplyModifier, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

self.textheader = u"%s %s" % (self.From, _("wrote:"))
if self.dformat == "html":
self.textheader = u"<p>{}</p>".format(self.textheader)
if hasattr(self, "Message_ID"):
self.form.fields["origmsgid"].initial = self.Message_ID
if not hasattr(self, "Reply_To"):
self.form.fields["to"].initial = self.From
self.form.fields["to"].initial = self.original_From
else:
self.form.fields["to"].initial = self.Reply_To
self.form.fields["to"].initial = self.original_ReplyTo
if self.request.GET.get("all", "0") == "1": # reply-all
self.form.fields["cc"].initial = ""
toparse = self.To.split(",")
Expand Down

0 comments on commit 99e5990

Please # to comment.