Re: [Mailman-Users] quote-trimming handler

2010-07-05 Thread Rob Lingelbach

On Jul 4, 2010, 

 Actually, that FAQ link used to go to the specific article which is now
 at http://wiki.list.org/x/l4A9 before the FAQ was moved.
 
 That FAQ discusses how to install custom handlers to do these kinds of
 things.

Thank you, I'll see if I can work up an understanding of it.

procmail recipes for enabling rejection :

http://www.animalgenome.org/SmartList/contrib/reject_garbage.txt

the specific recipe for rejecting a message with overquoting was this one 
below.  The weighting of quoted versus non-quoted lines, represented by the 
numbers 20 and -10, was arrived at by trial and error, and as I recall, was 
fairly lenient toward quoting so as not to make too many subscribers complain.  
Looks like I was pedantic enough in text of the rejection message.  Also, today 
the quoting is done with some form of rich text at times, is it not?
 

-cut here

# mine (rob a colorist.org , 1998)
:0 hBHw
*  20^1 ^
* -10^1 ^[^]
{
:0c
| formail -i Subject: ***quote REJECT engaged| $SENDMAIL -oi 
$maintainer

:0
| quotereject -attach
}

case $function in
  -attach)
($formail -iFrom: $listreq -rtAX-Loop: $listaddr  $tmprequest ;\
 $echo Your mail to the mailinglist has been intercepted and
 $echo is being returned to you because it it appears to the list server
 $echo to contain an excessive amount of quoted material.
 $echo Brief quoting is fine, but please quote only for context.
 $echo Do not quote other messages in their entirety, or quote
 $echo message headers or signature files.  
 $echo  
 $echo ...excessive quoting is a waste of resources.
 $echo If you feel that you've edited your message adequately but
 $echo it was still returned to you, you can appeal to the administator,
 $echo rob a colorist.org
 $echo  
 $echo [message follows]
 $echo  ; cat $tmprequest)\
 | $SENDMAIL $sendmailOPT $sender
shift ;;
esac

-cut here-

Rob
--
Rob Lingelbach
r...@colorist.org

--
Mailman-Users mailing list Mailman-Users@python.org
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org


Re: [Mailman-Users] quote-trimming handler

2010-07-05 Thread Mark Sapiro
Rob Lingelbach wrote:

the specific recipe for rejecting a message with overquoting was this one 
below.  The weighting of quoted versus non-quoted lines, represented by the 
numbers 20 and -10, was arrived at by trial and error, and as I recall, was 
fairly lenient toward quoting so as not to make too many subscribers complain. 
 Looks like I was pedantic enough in text of the rejection message.  Also, 
today the quoting is done with some form of rich text at times, is it not?
 

-cut here

# mine (rob a colorist.org , 1998)
:0 hBHw
*  20^1 ^
* -10^1 ^[^]


The attached Quoting.py is a handler which could be installed per the
FAQ at http://wiki.list.org/x/l4A9 to do essentially what it says in
its docstring.

If I understand your procmail conditions , they would correspond
roughly to RATIO = 0.5 in the attached, i.e. quoted lines = 0.5 *
unquoted lines, but not exactly because yours includes the message
headers which presumably would all be unquoted.

Also, the attached handler holds the message rather than rejects it,
although it could easily be changed to reject.

A proper implementation would make this hold/reject/discard decision a
list setting as well as making the ratio and the regexp for a quoted
line list settings too.

-- 
Mark Sapiro m...@msapiro.netThe highway is for gamblers,
San Francisco Bay Area, Californiabetter use your sense - B. Dylan

--
Mailman-Users mailing list Mailman-Users@python.org
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org


Re: [Mailman-Users] quote-trimming handler

2010-07-05 Thread Mark Sapiro
Mark Sapiro wrote:

The attached Quoting.py ...


This time, it's really attached (renamed Quoting.py.txt to get through
content filtering)

-- 
Mark Sapiro m...@msapiro.netThe highway is for gamblers,
San Francisco Bay Area, Californiabetter use your sense - B. Dylan

# Copyright (C) 2010 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.

Determine whether this message has excessive quoting.

This modules tests some messages for excessive quoting. It is pretty
simplistic. It looks only at the first text/plain message part if
any, thus it totally misses any HTML only messages if they pass
content filtering.

Also, this doesn't address the problem of a me too post with an
original message (often an entire digest) included without lines
prefixed by quoting characters.

It should come after MimeDel in the pipeline.
RATIO and QRE should be list settings.


import re

from Mailman import i18n
from Mailman import Errors
from Mailman.Handlers.Hold import hold_for_approval



# re for quoted line
QRE = re.compile('^\s*[:|]')
# re for blank lines
BLRE = re.compile('^\s*$')
# Ratio of quoted to unquoted lines considered excessive
RATIO = 1.0



def _(s):
return s

class ExcessiveQuoting(Errors.HoldMessage):
reason = _('Message has excessive quoting')
rejection = _(
'Your message has too high a ratio of quoted text to original text.')

# And reset the translator
_ = i18n._



def process(mlist, msg, msgdata):
if msgdata.get('approved'):
return
part = None
if msg.is_multipart():
for part in msg.walk():
if part.get_content_type() == 'text/plain':
break
else:
part = msg
if not part or part.get_content_type()  'text/plain':
return
# We now have the text/plain message or the first text/plain part
payload = part.get_payload(decode=True)
uql = ql = 0.0
for line in payload.splitlines():
if QRE.match(line):
ql += 1.0
elif not BLRE.match(line):
uql += 1.0
if uql == 0.0 or ql / uql = RATIO:
hold_for_approval(mlist, msg, msgdata, ExcessiveQuoting)
--
Mailman-Users mailing list Mailman-Users@python.org
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org

Re: [Mailman-Users] quote-trimming handler

2010-07-05 Thread Rob Lingelbach

On Jul 5, 2010, at 11:50 AM, Mark Sapiro wrote:

 This time, it's really attached (renamed Quoting.py.txt to get through
 content filtering)

This will be a lot of fun to look at and implement.  Holding the message is a 
much better option than a rejection.  And now I know how to sneak suitable 
attachments through Mailman.

--
Rob Lingelbach
r...@colorist.org

--
Mailman-Users mailing list Mailman-Users@python.org
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org


[Mailman-Users] quote-trimming handler

2010-07-04 Thread Rob Lingelbach
I would be very interested in hearing of various mechanisms for trimming 
over-quoting, including a hold on replies that match some kind of regexp.  I 
know about M. Sapiro's posting at 
http://mail.python.org/pipermail/mailman-users/2008-April/061227.html
which refers me (in the bottom link) to the FAQ _in toto_, but if there's a 
more pointed location or recent thread, I'd like to know.

Before I started running Mailman a decade or two ago, I used SmartList, for 
which I wrote and contributed a quote-aware filter.  I would be interested in 
contributing this work to Mailman if it hasn't already been done, or superseded 
by other concerns.

thank you in advance.
Rob

--
Rob Lingelbach
r...@colorist.org

--
Mailman-Users mailing list Mailman-Users@python.org
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org


Re: [Mailman-Users] quote-trimming handler

2010-07-04 Thread Mark Sapiro
Rob Lingelbach wrote:

I would be very interested in hearing of various mechanisms for trimming 
over-quoting, including a hold on replies that match some kind of regexp.  I 
know about M. Sapiro's posting at 
http://mail.python.org/pipermail/mailman-users/2008-April/061227.html
which refers me (in the bottom link) to the FAQ _in toto_, but if there's a 
more pointed location or recent thread, I'd like to know.


Actually, that FAQ link used to go to the specific article which is now
at http://wiki.list.org/x/l4A9 before the FAQ was moved.

That FAQ discusses how to install custom handlers to do these kinds of
things.


Before I started running Mailman a decade or two ago, I used SmartList, for 
which I wrote and contributed a quote-aware filter.  I would be interested in 
contributing this work to Mailman if it hasn't already been done, or 
superseded by other concerns.


I too would be interested if this is done using Python or if it can be
refactored for Python.

-- 
Mark Sapiro m...@msapiro.netThe highway is for gamblers,
San Francisco Bay Area, Californiabetter use your sense - B. Dylan

--
Mailman-Users mailing list Mailman-Users@python.org
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org