aboutsummaryrefslogtreecommitdiffstats
path: root/servo/models
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2015-12-02 11:02:41 +0200
committerFilipp Lepalaan <filipp@mac.com>2015-12-02 11:02:41 +0200
commitc4c4342a80d120c85238315a611a4a85fead79f1 (patch)
tree4affc634c976ae50d218f5e785b5d9dafe07bff5 /servo/models
parentb0327e0d012a50129ac7446d4ac35fdac8bd28d0 (diff)
downloadServo-c4c4342a80d120c85238315a611a4a85fead79f1.tar.gz
Servo-c4c4342a80d120c85238315a611a4a85fead79f1.tar.bz2
Servo-c4c4342a80d120c85238315a611a4a85fead79f1.zip
Ignore images in incoming emails
Diffstat (limited to 'servo/models')
-rw-r--r--servo/models/note.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/servo/models/note.py b/servo/models/note.py
index f5b8c15..ed8b944 100644
--- a/servo/models/note.py
+++ b/servo/models/note.py
@@ -231,7 +231,9 @@ class Note(MPTTModel):
return ' '.join(classes)
def find_parent(self, txt):
- """Finds the parent of this note"""
+ """
+ Finds the parent of this note
+ """
cookie = re.search(r'\(SRO#([\w/]+)\)', txt)
if not cookie:
@@ -250,7 +252,9 @@ class Note(MPTTModel):
@classmethod
def from_email(cls, msg, user):
- """Creates a new Note from an email message"""
+ """
+ Creates a new Note from an email message
+ """
sender = decode_header(msg['From'])
detected = chardet.detect(sender[0][0]).get('encoding')
sender = [i[0].decode(i[1] or detected) for i in sender]
@@ -276,7 +280,9 @@ class Note(MPTTModel):
payload = part.get_payload(decode=True)
note.body = unicode(payload, str(charset), "ignore")
if s == "html":
- note.body = html2text.html2text(note.body)
+ h = html2text.HTML2Text()
+ h.ignore_images = True
+ note.body = h.handle(note.body)
else:
note.save()
if part.get_filename():