[Mailman-Users] multiple footers accumulating on messages as discussion progresses - how to eliminate all but the last mailman footer?

Stephen J. Turnbull stephen at xemacs.org
Fri Apr 20 08:28:50 CEST 2012

On Fri, Apr 20, 2012 at 1:06 PM, David <dave at fiteyes.com> wrote:
> The main issue is that we include a personalized "instant unsubscribe" link
> in the footer, no password required. Our users seem to really want/need
> this.

Aha.  Now this all makes sense.

An alternative to requiring a password is to require confirmation via
their email address.  This does have the very undesirable feature that
users can still really annoy others by banging on their unsubscribe
link, thus resulting in spam to the targeted user.  But if it's not
deliberate harassment, this might help.  (It would also be possible,
but I suspect it's unimplemented, to refuse to send more than one
unsubscribe confirmation per time period.)

> Remove me from this list:
>  %(user_optionsurl)s?unsub=1&unsubconfirm=1&password=%(user_password)s

Ouch ... this presents a lot of opportunity for harrassment, since the
user's password will be sent around in clear.

> I can probably find a good regex that will recognize a URL and I can tailor
> that to match only URLs like the above. Given that, is there a custom
> module that is built to apply regular expressions for search/replace? I
> don't know Python. (But I would love to learn it when time permits.)

>>> import re
>>> cre = re.compile(r'some regex|other')
>>> result = cre.sub('', 'A string containing some other')
>>> print result
'A string containing '

The idiom is a little unintuitive; there is also a function re.sub you could use

result = re.sub(r'some regex|other', '', 'A string containing some other')

which gives the same result, marginally less efficiently.  (It used to
be that the regular expression was compiled fairly frequently if you
used the same regexp repeatedly, but now a fairly large number of
compiled regular expressions are cached, so the overhead is limited to
finding the right compiled regexp.)

For URLs in particular, you might want to look at the urlparse module.
 I don't remember how it's implemented but there's probably a regexp
for URLs in the source.

> Using that template for my purposes would require much more than changing a
> couple lines of code, so I don't think I can adapt/use it. I'm hoping
> someone has already created a handler for the purpose of doing a
> regex-based search/replace. Searching Google on "mailman search replace
> module OR handler" didn't turn up anything, however.

Do you understand how Handlers work?  What you do is put the code that
Mark suggested in a separate file in the Handlers directory, figure
out where you want the Handler to run, and then put

GLOBAL_PIPELINE.insert(position, 'ExcessFooterTrimmer')

in mm_cfg.py.

It's also possible to do this per list (eg, for testing on a single
list) by creating the Handler file, and instead of using the

$ cd /var/lib/mailman           # or whereever mailman's library code is
$ bin/withlist -i test-list
> m.lock()
> m.pipeline = GLOBAL_PIPELINE
> m.pipeline.insert(position, 'ExcessFooterTrimmer')
> m.save()
> quit()

If that sounds more reasonable, feel free to ask for more detailed and
accurate information (I'm just going off the top of my head here, but
the kind and amount of work involved is correct).

More information about the Mailman-Users mailing list