diff options
| author | klm | 1998-07-13 21:06:15 +0000 |
|---|---|---|
| committer | klm | 1998-07-13 21:06:15 +0000 |
| commit | 33e84008ff16989eec2f7c7b4fb53b3765c0fc15 (patch) | |
| tree | 3c0c52be32338dc555aae8bdb364ab46e24ff805 /Mailman/Digester.py | |
| parent | 49c76c3514fa4d5f86c59f57cbab9cf8c5bce4b1 (diff) | |
| download | mailman-33e84008ff16989eec2f7c7b4fb53b3765c0fc15.tar.gz mailman-33e84008ff16989eec2f7c7b4fb53b3765c0fc15.tar.zst mailman-33e84008ff16989eec2f7c7b4fb53b3765c0fc15.zip | |
Diffstat (limited to 'Mailman/Digester.py')
| -rw-r--r-- | Mailman/Digester.py | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/Mailman/Digester.py b/Mailman/Digester.py index e81fbed28..6b6a3ef6b 100644 --- a/Mailman/Digester.py +++ b/Mailman/Digester.py @@ -83,12 +83,11 @@ class Digester: 'How big in Kb should a digest be before it gets sent out?'), # Should offer a 'set to 0' for no size threshhold. -# ('digest_send_periodic', mm_cfg.Number, 3, 0, ('digest_send_periodic', mm_cfg.Radio, ('No', 'Yes'), 1, 'Should a digest be dispatched daily when the size threshold ' "isn't reached?"), - ('digest_header', mm_cfg.Text, (4, 55), 0, + ('digest_header', mm_cfg.Text, (4, 55), 0, 'Header added to every digest', "Text attached (as an initial message, before the table" " of contents) to the top of digests.<p>" @@ -391,8 +390,12 @@ class Digest: lines.append('Content-type: multipart/digest; boundary="%s"' % digestboundary) lines.append("") - lines.append(self.body) - + lines.append(self.body) + else: + lines.append( + filterDigestHeaders(self.body, + mm_cfg.DEFAULT_PLAIN_DIGEST_KEEP_HEADERS, + self.list._mime_separator)) # List-specific footer: if self.list.digest_footer: lines.append("") @@ -415,3 +418,50 @@ class Digest: msg.SetBody(string.join(lines, "\n")) return msg + +def filterDigestHeaders(body, keep_headers, mimesep): + """Return copy of body that omits non-crucial headers.""" + state = "sep" # "sep", "head", or "body" + lines = string.split(body, "\n") + at = 1 + text = [lines[0]] + kept_last = 0 + while at < len(lines): + l, at = lines[at], at + 1 + if state == "body": + # Snarf the body up to, and including, the next separator: + text.append(l) + if string.strip(l) == '--' + mimesep: + state = "sep" + continue + elif state == "sep": + state = "head" + # Keep the one (blank) line between separator and headers. + text.append(l) + kept_last = 0 + continue + elif state == "head": + l = string.strip(l) + if l == '': + state = "body" + text.append(l) + continue + elif l[0] in [' ', '\t']: + # Continuation line - keep if the prior line was kept. + if kept_last: + text.append(l) + continue + else: + where = string.find(l, ':') + if where == -1: + # Malformed header line - interesting, keep it. + text.append(l) + kept_last = 1 + else: + field = l[:where] + if string.lower(field) in keep_headers: + text.append(l) + kept_last = 1 + else: + kept_last = 0 + return string.join(text, '\n') |
