summaryrefslogtreecommitdiff
path: root/Mailman/Handlers
diff options
context:
space:
mode:
authorBarry Warsaw2008-01-13 16:17:38 -0500
committerBarry Warsaw2008-01-13 16:17:38 -0500
commit0d0c030d50e4dbd11f33ccddb96cf13fd3470cd2 (patch)
tree4e182668a895beabcb35a7659c37ac2fb04ca5bf /Mailman/Handlers
parent90355248db6f6619148abb2a9137c3a564345729 (diff)
downloadmailman-0d0c030d50e4dbd11f33ccddb96cf13fd3470cd2.tar.gz
mailman-0d0c030d50e4dbd11f33ccddb96cf13fd3470cd2.tar.zst
mailman-0d0c030d50e4dbd11f33ccddb96cf13fd3470cd2.zip
Add an interface IArchiver which is used to calculate urls and send messages
to the archiver. Also add a plugin architecture for easily overriding the archiver, and hook this into the setup.py script. Updated CookHeaders.py and Scrubber.py handlers to use the plugged archiver. Updated doctests as appropriate. Fix a typo in the setup.py file.
Diffstat (limited to '')
-rw-r--r--Mailman/Handlers/Cleanse.py2
-rw-r--r--Mailman/Handlers/CookHeaders.py16
-rw-r--r--Mailman/Handlers/Scrubber.py9
3 files changed, 18 insertions, 9 deletions
diff --git a/Mailman/Handlers/Cleanse.py b/Mailman/Handlers/Cleanse.py
index d84f988e3..05d8b5d3b 100644
--- a/Mailman/Handlers/Cleanse.py
+++ b/Mailman/Handlers/Cleanse.py
@@ -54,3 +54,5 @@ def process(mlist, msg, msgdata):
del msg['x-confirm-reading-to']
# Pegasus mail uses this one... sigh
del msg['x-pmrqc']
+ # Don't let this header be spoofed. See RFC 5064.
+ del msg['archived-at']
diff --git a/Mailman/Handlers/CookHeaders.py b/Mailman/Handlers/CookHeaders.py
index cb14853d5..0f558753a 100644
--- a/Mailman/Handlers/CookHeaders.py
+++ b/Mailman/Handlers/CookHeaders.py
@@ -26,7 +26,7 @@ from email.Utils import parseaddr, formataddr, getaddresses
from Mailman import Utils
from Mailman import Version
-from Mailman.app.archiving import get_base_archive_url
+from Mailman.app.archiving import get_archiver
from Mailman.configuration import config
from Mailman.i18n import _
from Mailman.interfaces import Personalization, ReplyToMunging
@@ -200,6 +200,7 @@ def process(mlist, msg, msgdata):
'List-Unsubscribe': subfieldfmt % (listinfo, mlist.leave_address),
'List-Subscribe' : subfieldfmt % (listinfo, mlist.join_address),
})
+ archiver = get_archiver()
if msgdata.get('reduced_list_headers'):
headers['X-List-Administrivia'] = 'yes'
else:
@@ -208,10 +209,17 @@ def process(mlist, msg, msgdata):
headers['List-Post'] = '<mailto:%s>' % mlist.posting_address
# Add this header if we're archiving
if mlist.archive:
- archiveurl = get_base_archive_url(mlist)
- if archiveurl.endswith('/'):
- archiveurl = archiveurl[:-1]
+ archiveurl = archiver.get_list_url(mlist)
headers['List-Archive'] = '<%s>' % archiveurl
+ # XXX RFC 2369 also defines a List-Owner header which we are not currently
+ # supporting, but should.
+ #
+ # Draft RFC 5064 defines an Archived-At header which contains the pointer
+ # directly to the message in the archive. If the currently defined
+ # archiver can tell us the URL, go ahead and include this header.
+ archived_at = archiver.get_message_url(mlist, msg)
+ if archived_at is not None:
+ headers['Archived-At'] = archived_at
# First we delete any pre-existing headers because the RFC permits only
# one copy of each, and we want to be sure it's ours.
for h, v in headers.items():
diff --git a/Mailman/Handlers/Scrubber.py b/Mailman/Handlers/Scrubber.py
index 6946de7f4..e5bb13778 100644
--- a/Mailman/Handlers/Scrubber.py
+++ b/Mailman/Handlers/Scrubber.py
@@ -35,7 +35,7 @@ from mimetypes import guess_all_extensions
from Mailman import Utils
from Mailman.Errors import DiscardMessage
-from Mailman.app.archiving import get_base_archive_url
+from Mailman.app.archiving import get_archiver
from Mailman.configuration import config
from Mailman.i18n import _
@@ -490,10 +490,9 @@ def save_attachment(mlist, msg, dir, filter_html=True):
fp = open(path, 'w')
fp.write(decodedpayload)
fp.close()
- # Now calculate the url
- baseurl = get_base_archive_url(mlist)
- # Private archives will likely have a trailing slash. Normalize.
- if baseurl[-1] <> '/':
+ # Now calculate the url to the list's archive.
+ baseurl = get_archiver().get_list_url(mlist)
+ if not baseurl.endswith('/'):
baseurl += '/'
# Trailing space will definitely be a problem with format=flowed.
# Bracket the URL instead.