You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by he...@apache.org on 2022/04/21 17:48:18 UTC

svn commit: r1900115 - in /spamassassin/trunk: MANIFEST lib/Mail/SpamAssassin/ArchiveIterator.pm t/bayesbdb.t t/bayesdbm.t t/bayessql.t t/data/nice.mbox

Author: hege
Date: Thu Apr 21 17:48:18 2022
New Revision: 1900115

URL: http://svn.apache.org/viewvc?rev=1900115&view=rev
Log:
Bug 7977 - sa-learn --mbox broken in trunk

Added:
    spamassassin/trunk/t/data/nice.mbox
Modified:
    spamassassin/trunk/MANIFEST
    spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
    spamassassin/trunk/t/bayesbdb.t
    spamassassin/trunk/t/bayesdbm.t
    spamassassin/trunk/t/bayessql.t

Modified: spamassassin/trunk/MANIFEST
URL: http://svn.apache.org/viewvc/spamassassin/trunk/MANIFEST?rev=1900115&r1=1900114&r2=1900115&view=diff
==============================================================================
--- spamassassin/trunk/MANIFEST (original)
+++ spamassassin/trunk/MANIFEST Thu Apr 21 17:48:18 2022
@@ -386,6 +386,7 @@ t/data/nice/spf5-received-spf-crlf
 t/data/nice/spf6-received-spf-crlf2
 t/data/nice/unicode1
 t/data/nice/unicode2
+t/data/nice.mbox
 t/data/phishing/openphish-feed.txt
 t/data/phishing/phishtank-feed.csv
 t/data/reporterplugin.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm?rev=1900115&r1=1900114&r2=1900115&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm Thu Apr 21 17:48:18 2022
@@ -415,7 +415,7 @@ sub _run_mailbox {
   my @msg;
   my $header;
 
-  my $fh = $self->_mail_open($where, 1);
+  my $fh = $self->_mail_open($file, 1);
   return unless $fh;
 
   my $opt_max_size = $self->{opt_max_size};
@@ -466,7 +466,7 @@ sub _run_mbx {
   my @msg;
   my $header;
 
-  my $fh = $self->_mail_open($where, 1);
+  my $fh = $self->_mail_open($file, 1);
   return unless $fh;
 
   my $opt_max_size = $self->{opt_max_size};

Modified: spamassassin/trunk/t/bayesbdb.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/bayesbdb.t?rev=1900115&r1=1900114&r2=1900115&view=diff
==============================================================================
--- spamassassin/trunk/t/bayesbdb.t (original)
+++ spamassassin/trunk/t/bayesbdb.t Thu Apr 21 17:48:18 2022
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -T
 
-use Data::Dumper;
+use File::Find qw(find);
 use lib '.'; use lib 't';
 use SATest; sa_t_init("bayesbdb");
 
@@ -16,7 +16,7 @@ plan skip_all => "BerkeleyDB is unavaila
   plan skip_all => "BerkeleyDB >= 4.6 is required" unless $BerkeleyDB::db_version >= 4.6;
 }
 
-plan tests => 42;
+plan tests => 46;
 
 
 tstprefs ("
@@ -155,15 +155,26 @@ tstprefs ("
 # our own checking callback and keep using the existing ok_all_patterns call
 %patterns = ( 1 => 'Acted on message' );
 
+$wanted_examined = count_files("data/spam");
 ok(salearnrun("--spam data/spam", \&check_examined));
 ok_all_patterns();
 
+$wanted_examined = count_files("data/nice");
 ok(salearnrun("--ham data/nice", \&check_examined));
 ok_all_patterns();
 
+$wanted_examined = count_files("data/whitelists");
 ok(salearnrun("--ham data/whitelists", \&check_examined));
 ok_all_patterns();
 
+$wanted_examined = 3;
+ok(salearnrun("--ham --mbox data/nice.mbox", \&check_examined));
+ok_all_patterns();
+
+$wanted_examined = 3;
+ok(salearnrun("--ham --mbox < data/nice.mbox", \&check_examined));
+ok_all_patterns();
+
 %patterns = ( 'non-token data: bayes db version' => 'db version' );
 ok(salearnrun("--dump magic", \&patterns_run_cb));
 ok_all_patterns();
@@ -243,7 +254,17 @@ sub check_examined {
     $_ = join ('', <IN>);
   }
 
-  if ($_ =~ /(?:Forgot|Learned) tokens from \d+ message\(s\) \(\d+ message\(s\) examined\)/) {
-    $found{'Acted on message'}++;
+  if ($_ =~ /(?:Forgot|Learned) tokens from \d+ message\(s\) \((\d+) message\(s\) examined\)/) {
+    #print STDERR "examined $1 messages\n";
+    if (defined $wanted_examined && $wanted_examined == $1) {
+      $found{'Acted on message'}++;
+    }
   }
 }
+
+sub count_files {
+  my $cnt = 0;
+  find({wanted => sub { $cnt++ if -f $_; }, no_chdir => 1}, $_[0]);
+  return $cnt;
+}
+

Modified: spamassassin/trunk/t/bayesdbm.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/bayesdbm.t?rev=1900115&r1=1900114&r2=1900115&view=diff
==============================================================================
--- spamassassin/trunk/t/bayesdbm.t (original)
+++ spamassassin/trunk/t/bayesdbm.t Thu Apr 21 17:48:18 2022
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -T
 
-use Data::Dumper;
+use File::Find qw(find);
 use lib '.'; use lib 't';
 use SATest; sa_t_init("bayesdbm");
 
@@ -10,7 +10,7 @@ use Test::More;
 
 plan skip_all => "Long running tests disabled" unless conf_bool('run_long_tests');
 plan skip_all => "DB_File is unavailable" unless HAS_DB_FILE;
-plan tests => 48;
+plan tests => 52;
 
 tstprefs ("
   bayes_learn_to_journal 0
@@ -175,15 +175,26 @@ tstprefs ("
 # our own checking callback and keep using the existing ok_all_patterns call
 %patterns = ( 1 => 'Acted on message' );
 
+$wanted_examined = count_files("data/spam");
 ok(salearnrun("--spam data/spam", \&check_examined));
 ok_all_patterns();
 
+$wanted_examined = count_files("data/nice");
 ok(salearnrun("--ham data/nice", \&check_examined));
 ok_all_patterns();
 
+$wanted_examined = count_files("data/whitelists");
 ok(salearnrun("--ham data/whitelists", \&check_examined));
 ok_all_patterns();
 
+$wanted_examined = 3;
+ok(salearnrun("--ham --mbox data/nice.mbox", \&check_examined));
+ok_all_patterns();
+
+$wanted_examined = 3;
+ok(salearnrun("--ham --mbox < data/nice.mbox", \&check_examined));
+ok_all_patterns();
+
 %patterns = ( 'non-token data: bayes db version' => 'db version' );
 ok(salearnrun("--dump magic", \&patterns_run_cb));
 ok_all_patterns();
@@ -263,9 +274,17 @@ sub check_examined {
     $_ = join ('', <IN>);
   }
 
-  if ($_ =~ /(?:Forgot|Learned) tokens from \d+ message\(s\) \(\d+ message\(s\) examined\)/) {
-    $found{'Acted on message'}++;
+  if ($_ =~ /(?:Forgot|Learned) tokens from \d+ message\(s\) \((\d+) message\(s\) examined\)/) {
+    #print STDERR "examined $1 messages\n";
+    if (defined $wanted_examined && $wanted_examined == $1) {
+      $found{'Acted on message'}++;
+    }
   }
 }
 
+sub count_files {
+  my $cnt = 0;
+  find({wanted => sub { $cnt++ if -f $_; }, no_chdir => 1}, $_[0]);
+  return $cnt;
+}
 

Modified: spamassassin/trunk/t/bayessql.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/bayessql.t?rev=1900115&r1=1900114&r2=1900115&view=diff
==============================================================================
--- spamassassin/trunk/t/bayessql.t (original)
+++ spamassassin/trunk/t/bayessql.t Thu Apr 21 17:48:18 2022
@@ -1,5 +1,6 @@
 #!/usr/bin/perl -T
 
+use File::Find qw(find);
 use lib '.'; use lib 't';
 use SATest; sa_t_init("bayessql");
 
@@ -14,8 +15,8 @@ plan skip_all => "DBI is unavailable on
 plan skip_all => "Bayes SQL tests are disabled or DBD::SQLite not found" unless (SQLITE || SQL);
 
 my $tests = 0;
-$tests += 53 if (SQLITE);
-$tests += 53 if (SQL);
+$tests += 57 if (SQLITE);
+$tests += 57 if (SQL);
 plan tests => $tests;
 
 diag "Note: Failure may be due to an incorrect config.";
@@ -339,15 +340,26 @@ tstprefs ("
 # our own checking callback and keep using the existing ok_all_patterns call
 %patterns = ( 1 => 'Acted on message' );
 
+$wanted_examined = count_files("data/spam");
 ok(salearnrun("--spam data/spam", \&check_examined));
 ok_all_patterns();
 
+$wanted_examined = count_files("data/nice");
 ok(salearnrun("--ham data/nice", \&check_examined));
 ok_all_patterns();
 
+$wanted_examined = count_files("data/whitelists");
 ok(salearnrun("--ham data/whitelists", \&check_examined));
 ok_all_patterns();
 
+$wanted_examined = 3;
+ok(salearnrun("--ham --mbox data/nice.mbox", \&check_examined));
+ok_all_patterns();
+
+$wanted_examined = 3;
+ok(salearnrun("--ham --mbox < data/nice.mbox", \&check_examined));
+ok_all_patterns();
+
 %patterns = ( 'non-token data: bayes db version' => 'db version' );
 ok(salearnrun("--dump magic", \&patterns_run_cb));
 ok_all_patterns();
@@ -450,11 +462,20 @@ sub check_examined {
     $_ = join ('', <IN>);
   }
 
-  if ($_ =~ /(?:Forgot|Learned) tokens from \d+ message\(s\) \(\d+ message\(s\) examined\)/) {
-    $found{'Acted on message'}++;
+  if ($_ =~ /(?:Forgot|Learned) tokens from \d+ message\(s\) \((\d+) message\(s\) examined\)/) {
+    #print STDERR "examined $1 messages\n";
+    if (defined $wanted_examined && $wanted_examined == $1) {
+      $found{'Acted on message'}++;
+    }
   }
 }
 
+sub count_files {
+  my $cnt = 0;
+  find({wanted => sub { $cnt++ if -f $_; }, no_chdir => 1}, $_[0]);
+  return $cnt;
+}
+
 # WARNING! Do not use this as an example, this breaks abstraction
 # and is here strictly to help the regression tests.
 sub database_clear_p {

Added: spamassassin/trunk/t/data/nice.mbox
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/data/nice.mbox?rev=1900115&view=auto
==============================================================================
--- spamassassin/trunk/t/data/nice.mbox (added)
+++ spamassassin/trunk/t/data/nice.mbox Thu Apr 21 17:48:18 2022
@@ -0,0 +1,217 @@
+From jm@dogma.slashnull.org  Wed May 16 00:40:34 2001
+Return-Path: <jm...@dogma.slashnull.org>
+Delivered-To: jm@netnoteinc.com
+Received: from dogma.slashnull.org (dogma.slashnull.org [212.17.35.15]) by
+    mail.netnoteinc.com (Postfix) with ESMTP id 830E5115158 for
+    <jm...@netnoteinc.com>; Tue, 15 May 2001 23:40:33 +0000 (Eire)
+Received: (from jm@localhost) by dogma.slashnull.org (8.9.3/8.9.3) id
+    AAA30873 for jm@netnoteinc.com; Wed, 16 May 2001 00:40:33 +0100
+Received: from trna.ximian.com ([141.154.95.22]) by dogma.slashnull.org
+    (8.9.3/8.9.3) with ESMTP id AAA30867 for <jm...@jmason.org>;
+    Wed, 16 May 2001 00:40:31 +0100
+Received: from trna.ximian.com (IDENT:nobody@localhost [127.0.0.1]) by
+    trna.ximian.com (8.9.3/8.9.3) with ESMTP id SAA19408; Tue, 15 May 2001
+    18:26:07 -0400
+Received: from milkplus (62-122-4-47.flat.galactica.it [62.122.4.47]) by
+    trna.ximian.com (8.9.3/8.9.3) with ESMTP id RAA19544; Tue, 15 May 2001
+    17:31:24 -0400
+Received: by milkplus (Postfix, from userid 1000) id D3FDD10B051;
+    Tue, 15 May 2001 17:31:22 -0400 (EDT)
+From: "Ximian, Inc." <ev...@ximian.com>
+To: announce@ximian.com
+Content-Type: text/plain
+X-Mailer: Evolution/0.10 (Preview Release)
+X-Loop: just so a test passes
+Date: 15 May 2001 17:31:22 -0400
+Message-Id: <98...@milkplus>
+MIME-Version: 1.0
+Subject: [HC Announce] Ximian Evolution 0.10 "Tasmanian Devil" is Now
+    Available!
+Sender: announce-admin@helixcode.com
+Errors-To: announce-admin@helixcode.com
+X-Mailman-Version: 1.1
+Precedence: bulk
+X-Hashcash: 0:040315:test@example.com:69781c87bae95c03
+X-hashcash: 1:20:040806:test1@example.com:test=foo:482b788d12eb9b56:2a3349
+List-Id: Announcements about Ximian. <announce.helixcode.com>
+X-Beenthere: announce@helixcode.com
+X-Spam-Status: No, hits=2 required=5
+
+A new preview release of Ximian Evolution is now available.  Evolution
+is a personal and workgroup information management tool that seamlessly
+combines email, calendar, address book and more.  Its extensive network
+support lets you connect to a wide range of services.  Release 0.10
+includes a host of new features and fixes.
+
+TO GET THE EVOLUTION PREVIEW RELEASE
+
+-   For those of you using Ximian GNOME, this version can be installed
+    by subscribing to the Evolution channel in Red Carpet (System -> Get
+    Software).
+
+-   To download the preview release from the Ximian web site, go to:
+    http://www.ximian.com/apps/evolution-preview/index.php3
+
+TO GET SOURCE CODE
+
+You can also get the Evolution source tarball here:
+
+        ftp://ftp.gnome.org/pub/GNOME/unstable/sources/evolution
+
+    Evolution also requires Gal (0.7), GtkHTML (0.8.2), Bonobo (1.0),
+    OAF (0.6.2), GNOME VFS (1.0), libunicode (0.4.gnome), GNOME Print
+    (0.25) and ORBit (0.5.6).
+
+        ftp://ftp.gnome.org/pub/GNOME/unstable/sources/gal
+        ftp://ftp.gnome.org/pub/GNOME/unstable/sources/gtkhtml
+        ftp://ftp.gnome.org/pub/GNOME/unstable/sources/bonobo
+        ftp://ftp.gnome.org/pub/GNOME/unstable/sources/oaf
+        ftp://ftp.gnome.org/pub/GNOME/unstable/sources/gnome-vfs
+        ftp://ftp.gnome.org/pub/GNOME/unstable/sources/libunicode
+        ftp://ftp.gnome.org/pub/GNOME/stable/sources/gnome-print
+        ftp://ftp.gnome.org/pub/GNOME/stable/sources/ORBit
+
+TO VIEW 0.10 RELEASE NOTES
+
+The 0.10 release notes are available at:
+http://www.ximian.com/newsitems/evolution-0.10-announce.php3
+
+
+
+_______________________________________________
+Announce maillist  -  Announce@helixcode.com
+http://lists.helixcode.com/mailman/listinfo/announce
+
+
+
+From nsb@thumper.bellcore.com Tue Oct  8 10:29:39 1991
+Received: from Tomobiki-Cho.CAC.Washington. (Tomobiki-Cho.CAC.Washington.EDU) by Ikkoku-Kan.Panda.COM
+	(NeXT-1.0 (From Sendmail 5.52)/UW-NDC Revision: 2.22 ) id AA12299; Tue, 8 Oct 91 07:29:39 PDT
+Return-Path: <ns...@thumper.bellcore.com>
+Received: from thumper.bellcore.com by Tomobiki-Cho.CAC.Washington.EDU
+	(NeXT-1.0 (From Sendmail 5.52)/UW-NDC Revision: 1.60.MRC ) id AA27545; Tue, 8 Oct 91 07:28:25 PDT
+Received: from greenbush.bellcore.com by thumper.bellcore.com (4.1/4.7)
+	id <AA08355> for mrc@panda.com; Tue, 8 Oct 91 10:25:41 EDT
+Received: by greenbush.bellcore.com (4.1/4.7)
+	id <AA00616> for mrc@panda.com; Tue, 8 Oct 91 10:25:36 EDT
+Date: Tue, 8 Oct 91 10:25:36 EDT
+From: nsb@thumper.bellcore.com (Nathaniel Borenstein)
+Message-Id: <91...@greenbush.bellcore.com>
+To: mrc@panda.com
+Subject:  Re: multipart mail
+MIME-Version: 1.0
+Content-Type: audio/basic
+Content-Transfer-Encoding: base64
+Content-Description: Hi Mark
+Status: RO
+
++Pv/d3RydWlnbGtnYWJiaWxqaWxucHrx7erk7X709Pfx6eXo5uXe3Ojw+Px1cXZra2dsbGdr
+
+From julliard@winehq.com Wed Sep  4 19:07:34 2002
+Received: (qmail 27859 invoked by uid 1001); 5 Sep 2002 02:25:41 -0000
+Received: from pop.pi.sbcglobal.net [207.115.63.84]
+	by localhost with POP3 (fetchmail-5.9.11 polling pop.sbcglobal.net account matt_relay)
+	for matt@localhost (single-drop); Wed, 04 Sep 2002 19:25:41 -0700 (PDT)
+Received: from vm4-ext.prodigy.net by vm4 with SMTP; Wed,  4 Sep 2002 22:26:20 -0400
+X-Originating-IP: [64.49.198.145]
+Received: from mail1.mailwizards.com (mail1.mailwizards.com [64.49.198.145])
+	by vm4-ext.prodigy.net (8.12.3 da nor stuldap/8.12.3) with ESMTP id g852QJix196066
+	for <ma...@sbcglobal.net>; Wed, 4 Sep 2002 22:26:19 -0400
+Received: from wine.codeweavers.com (wine.codeweavers.com [198.144.4.3])
+	by mail1.mailwizards.com (8.11.4/MW-2.03) with ESMTP id g852QIu06714
+	for <ma...@nightrealms.com>; Wed, 4 Sep 2002 21:26:18 -0500 (CDT)
+Received: from localhost.localdomain (wine [127.0.0.1])
+	by wine.codeweavers.com (8.11.6/8.11.6) with ESMTP id g852ClF25431;
+	Wed, 4 Sep 2002 21:12:47 -0500
+Received: from mail.wine.dyndns.org (12-235-88-76.client.attbi.com [12.235.88.76])
+	by wine.codeweavers.com (8.11.6/8.11.6) with ESMTP id g8527bF25126
+	for <wi...@winehq.com>; Wed, 4 Sep 2002 21:07:37 -0500
+Received: from mail.wine.dyndns.org (julliard@localhost [127.0.0.1])
+	by mail.wine.dyndns.org (8.12.3/8.12.3/Debian -4) with ESMTP id g8527Z0a029784
+	for <wi...@winehq.com>; Wed, 4 Sep 2002 19:07:35 -0700
+Received: (from julliard@localhost)
+	by mail.wine.dyndns.org (8.12.3/8.12.3/Debian -4) id g8527Zmq029780;
+	Wed, 4 Sep 2002 19:07:35 -0700
+To: wine-announce@winehq.com
+Subject: Wine release 20020904
+From: Alexandre Julliard <ju...@winehq.com>
+Message-ID: <87...@mail.wine.dyndns.org>
+Lines: 48
+User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp)
+MIME-Version: 1.0
+Content-Type: text/plain;
+  charset=us-ascii
+Sender: wine-announce-admin@winehq.com
+Errors-To: wine-announce-admin@winehq.com
+X-BeenThere: wine-announce@winehq.com
+X-Mailman-Version: 2.0
+Precedence: bulk
+Reply-To: wine-devel@winehq.com
+List-Help: <mailto:wine-announce-request@winehq.com?subject=help>
+List-Post: <ma...@winehq.com>
+List-Subscribe: <http://www.winehq.com/mailman/listinfo/wine-announce>,
+	<mailto:wine-announce-request@winehq.com?subject=subscribe>
+List-Id: Wine Announcements <wine-announce.winehq.com>
+List-Unsubscribe: <http://www.winehq.com/mailman/listinfo/wine-announce>,
+	<mailto:wine-announce-request@winehq.com?subject=unsubscribe>
+List-Archive: <http://www.winehq.com/hypermail/wine-announce/>
+Date: 04 Sep 2002 19:07:34 -0700
+X-DCC-wanadoo-be-Metrics: kagome 1016; Body=1 Fuz1=1 Fuz2=1
+X-Spam-Status: No, hits=-2.9 required=5.0
+	tests=KNOWN_MAILING_LIST,SPAM_PHRASE_03_05,SUBJ_HAS_UNIQ_ID,
+	      USER_AGENT
+	version=2.50-cvs
+X-Spam-Level: 
+Status: R 
+X-Status: N
+
+This is release 20020904 of Wine, a free implementation of Windows on
+Unix.  This is still a developers only release.  There are many bugs
+and unimplemented features.  Most applications still do not work
+correctly.
+
+Patches should be submitted to "wine-patches@winehq.com".  Please don't
+forget to include a ChangeLog entry.
+
+WHAT'S NEW with Wine-20020904: (see ChangeLog for details)
+	- Much improved PowerPC support.
+	- More correct locale definitions.
+	- Progress on the conversion of handle types to pointers.
+	- Many Visio and Quicken fixes merged from Crossover.
+	- Lots of bug fixes.
+
+See the README file in the distribution for installation instructions.
+
+Because of lags created by using mirror, this message may reach you before
+the release is available at the ftp sites.  The sources will be available
+from the following locations:
+
+  http://www.ibiblio.org/pub/Linux/ALPHA/wine/development/Wine-20020904.tar.gz
+  ftp://ftp.infomagic.com/pub/mirrors/linux/sunsite/ALPHA/wine/development/Wine-20020904.tar.gz
+  ftp://ftp.fu-berlin.de/unix/linux/mirrors/sunsite.unc.edu/ALPHA/wine/development/Wine-20020904.tar.gz
+  ftp://orcus.progsoc.uts.edu.au/pub/Wine/development/Wine-20020904.tar.gz
+
+It should also be available from any other site that mirrors ibiblio.org.
+For more download locations, see http://ftpsearch.lycos.com. These
+locations also hold pre-built documentation packages in various
+formats: wine-doc-html.tar.gz, wine-doc-txt.tar.gz, wine-doc.pdf.gz
+and wine-doc.ps.gz.
+
+You can also get the current source directly from the CVS tree. Check
+http://www.winehq.com/development/ for details.
+
+If you submitted a patch, please check to make sure it has been
+included in the new release.
+
+If you want to receive by mail a patch against the previous release
+when a new one is released, you can subscribe to the mailing list at
+http://tiger.informatik.hu-berlin.de/cgi-bin/mailman/listinfo/wine-patches.
+
+Wine is available thanks to the work of many people. See the file
+AUTHORS in the distribution for the complete list.
+
+--
+Alexandre Julliard
+julliard@winehq.com
+
+