Commit c3762c7f authored by Aurelien Campeas's avatar Aurelien Campeas
Browse files

pgp signature handling

parent e31d4151aec0
......@@ -129,3 +129,17 @@ class EmailITreeAdapter(adapters.ITreeAdapter):
__select__ = is_instance('Email')
tree_relation = 'reply_to'
class EmailThreadITreeAdapter(adapters.ITreeAdapter):
__select__ = is_instance('EmailThread')
tree_relation = 'in_thread'
class EmailPartIFTIAdapter(adapters.IFTIndexableAdapter):
__select__ = adapters.IFTIndexableAdapter.__select__ & is_instance('EmailPart')
def get_words(self):
try:
if self.entity.contenttype == 'application/pgp-signature':
return []
except AttributeError:
return super(EmailPartIFTIAdapter, self).get_words()
......@@ -22,6 +22,10 @@ def combinaison(list):
[(1, 2), (2, 3), (1, 3)]
>>> list(combinaison([1,2,3,4]))
[(1, 2), (2, 3), (3, 4), (1,3), (1,4), (2,4)]
note: in python 2.6, this can be written:
>>> import itertools
>>> itertools.combinations([1,2,3], 2)
"""
list = list[:]
while len(list) > 1:
......@@ -161,10 +165,12 @@ class MBOXImporter(object):
data = part.get_payload(decode=True)
if main == 'text':
encoding = u'UTF-8'
elif contenttype == 'application/pgp-signature':
encoding = u'ascii'
else:
encoding = None
name = part.get_filename()
if name or main != 'text':
if name or main != 'text' and contenttype != 'application/pgp-signature':
# suppose if we have a name, this is an attachement else this is a
# part/alternative
if not name and main != 'text':
......@@ -180,7 +186,12 @@ class MBOXImporter(object):
self.execute('SET X attachment Y WHERE X eid %(x)s, Y eid %(y)s',
{'x': emaileid, 'y': epart.eid})
else:
if isinstance(data, str):
data = unicode(data, encoding)
self._part_index += 1
self.req.set_shared_data('raw_content_%s_%s' %
(emaileid, self._part_index),
str(part.message))
epart = self.req.create_entity('EmailPart',
content=data,
content_format=contenttype,
......
......@@ -19,5 +19,6 @@ _afs.tag_subject_of(('*', 'generated_by', 'Email'), 'main', 'hidden')
class EmailPartIBreadCrumbsAdapter(ibreadcrumbs.IBreadCrumbsAdapter):
__select__ = is_instance('EmailPart')
def parent_entity(self):
return self.entity.thread
return self.entity.email
......@@ -57,6 +57,8 @@ class EmailPrimaryView(primary.PrimaryView):
content, mime = part.content, part.content_format
if mime == 'text/html':
content = soup2xhtml(content, self._cw.encoding)
elif 'pgp-signature' in mime:
content = entity._cw_mtc_transform(content, mime, 'text/html', self._cw.encoding)
elif mime != 'text/xhtml':
content = xml_escape(content)
if mime == 'text/plain':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment