/usr/lib/ezmlm-browse/commands/feed.py is in ezmlm-browse 0.10-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | from globals import *
from globalfns import *
import email
import feedgen
def rec_gettext(part):
if part.is_multipart():
return '\n'.join([ rec_gettext(p)
for p in part.get_payload() ])
if part.get_type('text/plain') == 'text/plain':
return part.get_payload(decode=1)
return ''
###############################################################################
# Command: Generate news feed
###############################################################################
def do(ctxt):
feedtype = feedgen.types[ctxt[FEEDTYPE]]
# Set a hard maximum on the number of messages to reduce DoS attacks
count = min(int(ctxt[FEEDMSGS]), 100)
num = ctxt[EZMLM].num
msgs = []
while len(msgs) < count and num > 0:
try:
msgs.append(ctxt[EZMLM].index[num])
except KeyError:
pass
num -= 1
for msg in msgs:
e = email.message_from_file(ctxt[EZMLM].open(int(msg[MSGNUM])))
msg[BODY] = rec_gettext(e).strip()
feedtype.generate(ctxt, msgs)
|