diff options
| author | toshio | 2012-03-14 05:30:52 +0000 |
|---|---|---|
| committer | toshio | 2012-03-14 05:30:52 +0000 |
| commit | d1a9979ecf35d05ed115651dcc6b8680af08b954 (patch) | |
| tree | cde5caa9a9c20467b4cb3768b564d08e6a368b1a /src/mailman/archiving | |
| parent | ccde42a936f6c87032c7afd80f33ca5f3fa00b54 (diff) | |
| parent | bcc42e2201c7172848185e5675a7b79e3d28aa0f (diff) | |
| download | mailman-d1a9979ecf35d05ed115651dcc6b8680af08b954.tar.gz mailman-d1a9979ecf35d05ed115651dcc6b8680af08b954.tar.zst mailman-d1a9979ecf35d05ed115651dcc6b8680af08b954.zip | |
Merge with upstream
Diffstat (limited to 'src/mailman/archiving')
| -rw-r--r-- | src/mailman/archiving/docs/common.rst | 25 | ||||
| -rw-r--r-- | src/mailman/archiving/mailarchive.py | 22 | ||||
| -rw-r--r-- | src/mailman/archiving/mhonarc.py | 20 | ||||
| -rw-r--r-- | src/mailman/archiving/prototype.py | 18 |
4 files changed, 33 insertions, 52 deletions
diff --git a/src/mailman/archiving/docs/common.rst b/src/mailman/archiving/docs/common.rst index 7fe788ee4..7bee8c70e 100644 --- a/src/mailman/archiving/docs/common.rst +++ b/src/mailman/archiving/docs/common.rst @@ -11,6 +11,7 @@ archivers. ... To: test@example.com ... Subject: An archived message ... Message-ID: <12345> + ... X-Message-ID-Hash: RSZCG7IGPHFIRW3EMTVMMDNJMNCVCOLE ... ... Here is an archived message. ... """) @@ -33,7 +34,7 @@ interoperate. ... archivers[archiver.name] = archiver mail-archive http://go.mail-archive.dev/test%40example.com - http://go.mail-archive.dev/ZaXPPxRMM9_hFZL4vTRlQlBx8pc= + http://go.mail-archive.dev/RSZCG7IGPHFIRW3EMTVMMDNJMNCVCOLE mhonarc http://lists.example.com/.../test@example.com http://lists.example.com/.../RSZCG7IGPHFIRW3EMTVMMDNJMNCVCOLE @@ -84,7 +85,7 @@ messages to public lists will get sent there automatically. >>> print archiver.list_url(mlist) http://go.mail-archive.dev/test%40example.com >>> print archiver.permalink(mlist, msg) - http://go.mail-archive.dev/ZaXPPxRMM9_hFZL4vTRlQlBx8pc= + http://go.mail-archive.dev/RSZCG7IGPHFIRW3EMTVMMDNJMNCVCOLE To archive the message, the archiver actually mails the message to a special address at The Mail Archive. The message gets no header or footer decoration. @@ -107,7 +108,7 @@ address at The Mail Archive. The message gets no header or footer decoration. To: test@example.com Subject: An archived message Message-ID: <12345> - X-Message-ID-Hash: ZaXPPxRMM9_hFZL4vTRlQlBx8pc= + X-Message-ID-Hash: RSZCG7IGPHFIRW3EMTVMMDNJMNCVCOLE X-Peer: 127.0.0.1:... X-MailFrom: test-bounces@example.com X-RcptTo: archive@mail-archive.dev @@ -131,26 +132,36 @@ at this service. Additionally, this archiver can handle malformed ``Message-IDs``. :: + >>> from mailman.utilities.email import add_message_hash >>> mlist.archive_private = False >>> del msg['message-id'] + >>> del msg['x-message-id-hash'] >>> msg['Message-ID'] = '12345>' + >>> add_message_hash(msg) >>> print archiver.permalink(mlist, msg) - http://go.mail-archive.dev/bXvG32YzcDEIVDaDLaUSVQekfo8= + http://go.mail-archive.dev/YJIGBYRWZFG5LZEBQ7NR25B5HBR2BVD6 >>> del msg['message-id'] + >>> del msg['x-message-id-hash'] >>> msg['Message-ID'] = '<12345' + >>> add_message_hash(msg) >>> print archiver.permalink(mlist, msg) - http://go.mail-archive.dev/9rockPrT1Mm-jOsLWS6_hseR_OY= + http://go.mail-archive.dev/XUFFJNJ2P2WC4NDPQRZFDJMV24POP64B >>> del msg['message-id'] + >>> del msg['x-message-id-hash'] >>> msg['Message-ID'] = '12345' + >>> add_message_hash(msg) >>> print archiver.permalink(mlist, msg) - http://go.mail-archive.dev/ZaXPPxRMM9_hFZL4vTRlQlBx8pc= + http://go.mail-archive.dev/RSZCG7IGPHFIRW3EMTVMMDNJMNCVCOLE >>> del msg['message-id'] + >>> del msg['x-message-id-hash'] + >>> add_message_hash(msg) >>> msg['Message-ID'] = ' 12345 ' + >>> add_message_hash(msg) >>> print archiver.permalink(mlist, msg) - http://go.mail-archive.dev/ZaXPPxRMM9_hFZL4vTRlQlBx8pc= + http://go.mail-archive.dev/RSZCG7IGPHFIRW3EMTVMMDNJMNCVCOLE MHonArc diff --git a/src/mailman/archiving/mailarchive.py b/src/mailman/archiving/mailarchive.py index 29c0e22c2..c72cde11c 100644 --- a/src/mailman/archiving/mailarchive.py +++ b/src/mailman/archiving/mailarchive.py @@ -25,9 +25,6 @@ __all__ = [ ] -import hashlib - -from base64 import urlsafe_b64encode from urllib import quote from urlparse import urljoin from zope.interface import implements @@ -60,21 +57,12 @@ class MailArchive: """See `IArchiver`.""" if mlist.archive_private: return None - message_id = msg.get('message-id') - # It is not the archiver's job to ensure the message has a Message-ID. - # If no Message-ID is available, there is no permalink. - if message_id is None: + # It is the LMTP server's responsibility to ensure that the message + # has a X-Message-ID-Hash header. If it doesn't then there's no + # permalink. + message_id_hash = msg.get('x-message-id-hash') + if message_id_hash is None: return None - # The angle brackets are not part of the Message-ID. See RFC 2822. - if message_id.startswith('<') and message_id.endswith('>'): - message_id = message_id[1:-1] - else: - message_id = message_id.strip() - sha = hashlib.sha1(message_id) - sha.update(str(mlist.posting_address)) - message_id_hash = urlsafe_b64encode(sha.digest()) - del msg['x-message-id-hash'] - msg['X-Message-ID-Hash'] = message_id_hash return urljoin(config.archiver.mail_archive.base_url, message_id_hash) @staticmethod diff --git a/src/mailman/archiving/mhonarc.py b/src/mailman/archiving/mhonarc.py index db0b12c3d..0beeed73e 100644 --- a/src/mailman/archiving/mhonarc.py +++ b/src/mailman/archiving/mhonarc.py @@ -25,11 +25,9 @@ __all__ = [ ] -import hashlib import logging import subprocess -from base64 import b32encode from urlparse import urljoin from zope.interface import implements @@ -63,20 +61,12 @@ class MHonArc: def permalink(mlist, msg): """See `IArchiver`.""" # XXX What about private MHonArc archives? - message_id = msg.get('message-id') - # It is not the archiver's job to ensure the message has a Message-ID. - # If no Message-ID is available, there is no permalink. - if message_id is None: + # It is the LMTP server's responsibility to ensure that the message + # has a X-Message-ID-Hash header. If it doesn't then there's no + # permalink. + message_id_hash = msg.get('x-message-id-hash') + if message_id_hash is None: return None - # The angle brackets are not part of the Message-ID. See RFC 2822. - if message_id.startswith('<') and message_id.endswith('>'): - message_id = message_id[1:-1] - else: - message_id = message_id.strip() - sha = hashlib.sha1(message_id) - message_id_hash = b32encode(sha.digest()) - del msg['x-message-id-hash'] - msg['X-Message-ID-Hash'] = message_id_hash return urljoin(MHonArc.list_url(mlist), message_id_hash) @staticmethod diff --git a/src/mailman/archiving/prototype.py b/src/mailman/archiving/prototype.py index 266b1da07..be6c60475 100644 --- a/src/mailman/archiving/prototype.py +++ b/src/mailman/archiving/prototype.py @@ -63,20 +63,12 @@ class Prototype: @staticmethod def permalink(mlist, msg): """See `IArchiver`.""" - message_id = msg.get('message-id') - # It is not the archiver's job to ensure the message has a Message-ID. - # If this header is missing, there is no permalink. - if message_id is None: + # It is the LMTP server's responsibility to ensure that the message + # has a X-Message-ID-Hash header. If it doesn't then there's no + # permalink. + message_id_hash = msg.get('x-message-id-hash') + if message_id_hash is None: return None - # The angle brackets are not part of the Message-ID. See RFC 2822. - if message_id.startswith('<') and message_id.endswith('>'): - message_id = message_id[1:-1] - else: - message_id = message_id.strip() - digest = hashlib.sha1(message_id).digest() - message_id_hash = b32encode(digest) - del msg['x-message-id-hash'] - msg['X-Message-ID-Hash'] = message_id_hash return urljoin(Prototype.list_url(mlist), message_id_hash) @staticmethod |
