summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurélien Bompard <aurelien@bompard.org>2012-10-02 18:54:10 +0200
committerAurélien Bompard <aurelien@bompard.org>2012-10-02 18:54:10 +0200
commit5784ad8bfd783487aa8a6abd1e4bb689874f8c67 (patch)
treef2c1aca8ef7c8c52b90f66921c9ad4409014c224
parent6cce8b8dc1501e992c3c036fb888a15db7c1bca0 (diff)
downloadkittystore-5784ad8bfd783487aa8a6abd1e4bb689874f8c67.tar.gz
kittystore-5784ad8bfd783487aa8a6abd1e4bb689874f8c67.tar.xz
kittystore-5784ad8bfd783487aa8a6abd1e4bb689874f8c67.zip
Use the email.utils.unquote function
-rw-r--r--kittystore/scrub.py4
-rw-r--r--kittystore/storm/store.py3
-rw-r--r--kittystore/utils.py2
3 files changed, 5 insertions, 4 deletions
diff --git a/kittystore/scrub.py b/kittystore/scrub.py
index 3b1532a..8c98803 100644
--- a/kittystore/scrub.py
+++ b/kittystore/scrub.py
@@ -27,7 +27,7 @@ from cStringIO import StringIO
from types import IntType, StringType
from mimetypes import guess_all_extensions
-from email.Utils import parsedate
+from email.Utils import parsedate, unquote
from email.Parser import HeaderParser
from email.Generator import Generator
from email.Charset import Charset
@@ -294,7 +294,7 @@ class Scrubber(object):
## BAW: I'm sure we can eventually do better than this. :(
#decodedpayload = websafe(str(submsg))
decodedpayload = str(submsg)
- msg_id = self.msg['Message-Id'].strip("<>")
+ msg_id = unquote(self.msg['Message-Id'])
self.store.add_attachment(
self.mlist, msg_id, counter, filebase+ext,
ctype, charset, decodedpayload)
diff --git a/kittystore/storm/store.py b/kittystore/storm/store.py
index cb0b486..c5cad84 100644
--- a/kittystore/storm/store.py
+++ b/kittystore/storm/store.py
@@ -15,6 +15,7 @@ license.
from __future__ import absolute_import
import datetime
+from email.utils import unquote
from kittystore import MessageNotFound
from kittystore.utils import parseaddr, parsedate
@@ -87,7 +88,7 @@ class StormStore(object):
self.db.add(List(list_name))
if not message.has_key("Message-Id"):
raise ValueError("No 'Message-Id' header in email", message)
- msg_id = unicode(message['Message-Id'].strip("<>"))
+ msg_id = unicode(unquote(message['Message-Id']))
email = Email(list_name, msg_id)
if self.is_message_in_list(list_name, email.message_id):
print ("Duplicate email from %s: %s" %
diff --git a/kittystore/utils.py b/kittystore/utils.py
index 5b7eb10..90b9d15 100644
--- a/kittystore/utils.py
+++ b/kittystore/utils.py
@@ -45,7 +45,7 @@ def get_message_id_hash(msg_id):
'JJIGKPKB6CVDX6B2CUG4IHAJRIQIOUTP'
"""
- msg_id = msg_id.strip("<>")
+ msg_id = email.utils.unquote(msg_id)
return b32encode(sha1(msg_id).digest())