[prev in list] [next in list] [prev in thread] [next in thread] 

List:       spamassassin-devel
Subject:    [Bug 7674] sa-learn learns all messages as ham even if --spam is specified
From:       bugzilla-daemon () bugzilla ! spamassassin ! org
Date:       2019-01-13 14:29:13
Message-ID: bug-7674-26-GMgNcgNmIj () https ! bz ! apache ! org/SpamAssassin/
[Download RAW message or body]

https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7674

--- Comment #4 from Ralf Glauberman <ralfglauberman@gmx.de> ---
Sorry for the delay, needed to debug it in more detail...

I still don't know why you are unable to reproduce the bug but i am sure it is
not related to the debug switch. I was able to reproduce the problem with a
clean install and default konfiguration (i.e. no MySQL or anything). To debug
the problem I added the following line to sa-learn in the wanted function (at
about line 576):

+  warn "learning $id as $class\n";
   my $status = $spamtest->learn( $ma, undef, $spam, $forget );

Executing the following command then returns:

./bin/sa-learn --spam test.eml --ham test2.eml --spam test3.eml
learning test.eml as s
learning test3.eml as s
learning test2.eml as h
Learned tokens from 2 message(s) (3 message(s) examined)

=> Works as intended

In order to be able to learn spam and ham messages during one execution of the
command, the command line is parsed and each message to learn is added to the
targets array by the target function. The function uses the global isspam
variable to determine if the message should be learned as spam or as ham. This
variable is set whenever a --spam/--ham command line parameter is read by
GetOptions. This means however that if a message file name is found on the
command line before any --spam/--ham flag, the isspam variable has never been
initialized by the time target is called and the behavior is therefore
undefined. The statement "my $class = ( $isspam ? "spam" : "ham" );" results in
the message being learned as ham.

./bin/sa-learn test.eml --ham test2.eml --spam test3.eml
learning test3.eml as s
learning test.eml as h
learning test2.eml as h
Learned tokens from 2 message(s) (3 message(s) examined)

Or with just one message:
./bin/sa-learn test.eml --spam
learning test.eml as h
Learned tokens from 0 message(s) (1 message(s) examined)

I think the program should check that --spam/--ham has been seen on the command
line before any message file name and the documentation should be updated so it
is clear that both spam and ham can be learned during a single execution but
the relevant flag has to be used before the file name.

Sorry for not providing a patch but I don't know perl (read only).

-- 
You are receiving this mail because:
You are the assignee for the bug.=
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic