mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
@@ -102,6 +102,7 @@ class BodyStructure(object):
|
||||
extensions = ["envelopestruct", "bodystruct", "textlines"] + extensions
|
||||
for idx, value in enumerate(definition[7:]):
|
||||
params[extensions[idx]] = value
|
||||
|
||||
self.attachments += [params]
|
||||
|
||||
def load_from_definition(self, definition, multisubtype=None):
|
||||
|
||||
@@ -180,19 +180,27 @@ class ImapEmail(Email):
|
||||
|
||||
mformat = self.dformat if self.bs.contents.has_key(self.dformat) else fallback_fmt
|
||||
|
||||
pnum = self.bs.contents[mformat]['pnum']
|
||||
data = self.imapc._cmd("FETCH", mailid, "(BODY.PEEK[%s])" % pnum)
|
||||
content = decode_payload(self.bs.contents[mformat]['encoding'],
|
||||
data[int(mailid)]['BODY[%s]' % pnum])
|
||||
charset = self._find_content_charset(mformat)
|
||||
if charset is not None:
|
||||
content = content.decode(charset)
|
||||
if len(self.bs.contents):
|
||||
pnum = self.bs.contents[mformat]['pnum']
|
||||
data = self.imapc._cmd("FETCH", mailid, "(BODY.PEEK[%s])" % pnum)
|
||||
content = decode_payload(self.bs.contents[mformat]['encoding'],
|
||||
data[int(mailid)]['BODY[%s]' % pnum])
|
||||
charset = self._find_content_charset(mformat)
|
||||
if charset is not None:
|
||||
try:
|
||||
content = content.decode(charset)
|
||||
except (UnicodeDecodeError, LookupError):
|
||||
import chardet
|
||||
result = chardet.detect(content)
|
||||
content = content.decode(result['encoding'])
|
||||
|
||||
self._fetch_inlines()
|
||||
self.body = \
|
||||
getattr(self, "viewmail_%s" % mformat)(content, links=links)
|
||||
else:
|
||||
self.body = None
|
||||
|
||||
self._find_attachments()
|
||||
self._fetch_inlines()
|
||||
|
||||
self.body = \
|
||||
getattr(self, "viewmail_%s" % mformat)(content, links=links)
|
||||
|
||||
msg = email.message_from_string(headers)
|
||||
for hdr in self.headernames:
|
||||
|
||||
@@ -40,9 +40,9 @@ def getattachment(request):
|
||||
resp["Content-Transfer-Encoding"] = partdef["encoding"]
|
||||
if partdef["disposition"] != 'NIL':
|
||||
disp = partdef["disposition"]
|
||||
cd = "%s; %s=%s" % (disp[0], disp[1][0], disp[1][1])
|
||||
cd = '%s; %s="%s"' % (disp[0], disp[1][0], disp[1][1])
|
||||
else:
|
||||
cd = "attachment; filename=%s" % request.GET["fname"]
|
||||
cd = 'attachment; filename="%s"' % request.GET["fname"]
|
||||
resp["Content-Disposition"] = cd
|
||||
resp["Content-Length"] = partdef["size"]
|
||||
return resp
|
||||
@@ -408,7 +408,7 @@ def getmailcontent(request):
|
||||
email = ImapEmail(mbox, mailid, request, links=int(request.GET["links"]))
|
||||
return _render(request, "common/viewmail.html", {
|
||||
"headers" : email.render_headers(folder=mbox, mail_id=mailid),
|
||||
"folder" : mbox, "imapid" : mailid, "mailbody" : email.body
|
||||
"folder" : mbox, "imapid" : mailid, "mailbody" : email.body if email.body else ""
|
||||
})
|
||||
|
||||
def viewmail(request):
|
||||
|
||||
@@ -3,3 +3,4 @@ south
|
||||
lxml
|
||||
pycrypto
|
||||
sievelib
|
||||
chardet
|
||||
|
||||
Reference in New Issue
Block a user