--- filter_nnrpd.pl.orig Wed May 15 05:02:42 2002 +++ filter_nnrpd.pl Thu Dec 12 00:03:39 2002 @@ -13,6 +13,16 @@ # in the rejection message. # +# +# Do any initialization steps. +# +my %config = (checkincludedtext => 0, + includedcutoff => 40, + includedratio => 0.6, + quotere => '^[>:]', + antiquotere => '^[<]', # so as not to reject dict(1) output + ); + # # Sample filter @@ -33,6 +43,32 @@ ## $rval = "From: is invalid, must be user\@[host.]domain.tld"; ## } + +### The next block rejects articles with too much quoted text, if the +### config hash directs it to. + + if ($config{checkincludedtext}) { + my ($lines, $quoted, $antiquoted) = analyze($body); + if ($lines > $config{includedcutoff} + && $quoted - $antiquoted > $lines * $config{includedratio}) { + $rval = "Article contains too much quoted text"; + } + } + return $rval; } +sub analyze { + my ($lines, $quoted, $antiquoted) = (0, 0, 0); + local $_ = shift; + + do { + if ( /\G$config{quotere}/mgc ) { + $quoted++; + } elsif ( /\G$config{antiquotere}/mgc ) { + $antiquoted++; + } + } while ( /\G(.*)\n/gc && ++$lines ); + + return ($lines, $quoted, $antiquoted); +}