summaryrefslogtreecommitdiff
path: root/src/mailman/model/messagestore.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/model/messagestore.py')
-rw-r--r--src/mailman/model/messagestore.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mailman/model/messagestore.py b/src/mailman/model/messagestore.py
index 225d3d1ce..0b8a0ac78 100644
--- a/src/mailman/model/messagestore.py
+++ b/src/mailman/model/messagestore.py
@@ -66,7 +66,7 @@ class MessageStore:
'Message ID already exists in message store: {0}'.format(
message_id))
shaobj = hashlib.sha1(message_id)
- hash32 = base64.b32encode(shaobj.digest()).decode('ascii')
+ hash32 = base64.b32encode(shaobj.digest())
del message['X-Message-ID-Hash']
message['X-Message-ID-Hash'] = hash32
# Calculate the path on disk where we're going to store this message
@@ -115,8 +115,12 @@ class MessageStore:
@dbconnection
def get_message_by_hash(self, store, message_id_hash):
- if isinstance(message_id_hash, bytes):
- message_id_hash = message_id_hash.decode('utf-8')
+ # It's possible the hash came from a message header, in which case it
+ # will be a Unicode. However when coming from source code, it may be
+ # an 8-string. Coerce to the latter if necessary; it must be
+ # US-ASCII.
+ if isinstance(message_id_hash, unicode):
+ message_id_hash = message_id_hash.encode('ascii')
row = store.query(Message).filter_by(
message_id_hash=message_id_hash).first()
if row is None: