]> git.pld-linux.org Git - packages/mailman.git/blame - keep-original-mime-headers.patch
systemd and systemd-cronjobs support added
[packages/mailman.git] / keep-original-mime-headers.patch
CommitLineData
064d962f
ER
1save original mime headers from attachment to .raw file and send them back when
2attachment is accessed over cgi. as the logistic of saving attachment with
3filename is quite unreliable, even if the content-types match for input and
4output the filename extension offered may make no sense on client computer.
5
6for example input email has:
7Name: test.rtf
8Type: application/msword
9Size: 17084 bytes
10
11Mailman will detect from mimetype .dot extension:
12python -c 'from mimetypes import guess_all_extensions; print guess_all_extensions("application/msword");'
13['.wiz', '.dot', '.doc']
14
15and save as test.wiz, client will request such file, and will get:
16Content-Type: application/msword
17
18and will save as test.wiz, now client desktop has no ideas how to open .wiz
19file and has to rename file manually to .rtf to actually being able top open it
20with double click.
21
22saving and sending original headers ensures we get original filename that was
23in email. works for private archives but unfortunately as public archives are
24sent out direcly by webserver which we have no control over the extra headers
25to send. (altho if we mod_asis could work here, but that means totally
26incompatible storage from previous versions)
27
28Signed-off-by: Elan Ruusamäe <glen@delfi.ee>
29--- mailman-2.1.13/Mailman/Cgi/private.py~ 2010-08-27 14:28:41.000000000 +0300
30+++ mailman-2.1.13/Mailman/Cgi/private.py 2010-08-27 14:28:45.036366738 +0300
c1b83866 31@@ -175,6 +175,12 @@
064d962f
ER
32 f = gzip.open(true_filename, 'r')
33 else:
34 f = open(true_filename, 'r')
c1b83866
ER
35+ if mm_cfg.ARCHIVER_STORES_ATTACHMENT_HEADERS:
36+ # if .raw exists, dump it out as it contains extra headers
37+ if os.path.exists(true_filename + '.raw'):
38+ fh = open(true_filename + '.raw', 'r')
39+ sys.stdout.write(fh.read())
40+ fh.close()
064d962f
ER
41 except IOError:
42 msg = _('Private archive file not found')
43 doc.SetTitle(msg)
44--- mailman-2.1.13/Mailman/Handlers/Scrubber.py~ 2010-08-27 15:27:27.000000000 +0300
45+++ mailman-2.1.13/Mailman/Handlers/Scrubber.py 2010-08-27 15:27:33.452165228 +0300
c1b83866 46@@ -520,6 +520,15 @@
064d962f
ER
47 fp = open(path, 'w')
48 fp.write(decodedpayload)
49 fp.close()
50+
51+ # print Content-Type and Content-Disposition we found to .raw for Cgi.private to use
c1b83866
ER
52+ if mm_cfg.ARCHIVER_STORES_ATTACHMENT_HEADERS:
53+ f = open(path + '.raw', 'w')
54+ for k, v in msg.items():
55+ if k.lower() in ['content-type', 'content-disposition']:
8223798f 56+ f.write("%s: %s\n" % (k, v.replace("\n ", " ").replace("\n\t", " ")))
c1b83866 57+ f.close()
064d962f
ER
58+
59 # Now calculate the url
60 baseurl = mlist.GetBaseArchiveURL()
61 # Private archives will likely have a trailing slash. Normalize.
aafb0425
ER
62--- mailman-2.1.13/Mailman/Defaults.py.in~ 2010-08-27 17:48:45.000000000 +0300
63+++ mailman-2.1.13/Mailman/Defaults.py.in 2010-08-29 16:15:45.888393508 +0300
c1b83866
ER
64@@ -335,6 +335,11 @@
65 # in the archives too.
66 ARCHIVER_OBSCURES_EMAILADDRS = Yes
67
68+# Whether archive stores attachment headers which contain original MIME type
69+# and filenames For private archives those headers are sent back as well when
70+# serving content. Note that this changes behaviour and maybe insecure.
71+ARCHIVER_STORES_ATTACHMENT_HEADERS = No
72+
73 # Pipermail assumes that message bodies contain US-ASCII text.
74 # Change this option to define a different character set to be used as
75 # the default character set for the archive. The term "character set"
This page took 0.029367 seconds and 4 git commands to generate.