🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #27362

An alternative to regex based filtering

#27362
From: Joe St Sauver
Date: Wed, 01 Apr 1998 00:00
36 lines
1916 bytes
If you are currently using Clean Feed for filtering and have a large-ish
locally augmented list of $badguys, or if you are shunning a number of sites
via ME entries in your newsfeeds file, the following perl code may be faster 
than a large regex for you (or then again, maybe not). Anyhow:

  [above sub filter_art]

    open (INPUT, "/news/path-headers.txt") || 
       die "can not open /news/path-headers.txt\n";
    while (<INPUT>) { chop; $ptoken{$_}=1; } close (INPUT);

    open (INPUT, "/news/tokens.txt") || 
       die "can not open /news/tokens.txt\n";
    while (<INPUT>) { chop; $token{$_}=1; } close (INPUT);

  [within sub filter_art]

    @pathtokens = (split(/[\!]+/o,$hdr{'Path'}));
    foreach $word (@pathtokens)
       {return "Unwanted-Path: $word\n" if $ptoken{($word)}; }

    @testtokens = (split(/[ \t\@\!\.\"\'\_]+/o,lc($hdr{'From'})));
    foreach $word (@testtokens)
       {return "Unwanted-From: $word\n" if $token{($word)}; }

Regards,

Joe

Disclaimer: no warranties express or implied, this code is only provided
for illustration/conceptual discussion purposes and would require extensive 
modification and embellishment before it could possibly be fast or stable 
enough to use in a production environment, etc., etc., etc. 

Technical Details
Message-ID: <6fs9dl$dtd$1@pith.uoregon.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <6fs9dl$dtd$1@pith.uoregon.edu>
Subject: An alternative to regex based filtering
Date: Wed, 01 Apr 1998 00:00:00 +0000
From: joe@decoy.uoregon.edu (Joe St Sauver)
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 339705354
X-Complaints-To: usenet@news.uoregon.edu
X-Trace: pith.uoregon.edu 891398389 14253 (None) 128.223.32.68
Organization: University of Oregon, Eugene
Newsgroups: news.software.nntp