Version: (using KDE KDE 3.3.1) Installed from: Debian testing/unstable Packages OS: Linux Spamassassin can modify spam mails to include a verbose report. When marking a message as "NOT spam" using the wizard-supplied filter, this markup is not removed. This is very easy to change. The filter just neds to pipe the mmail through "spamassassin -d" to restore the original state. In my opinion, this would be a very useful default action since the call is almost free.
Not changed in KMail 1.8.
This requires a rewrite fo a part of the logic behind the anti-spam wizard. A general solution for all the other supported anti-spam tools should be considered.
You can easily do this by piping the message through spamassassin -d, which is an option for defining filters. That's how I do it. So this would only change the anti-spam wizard, since the rest of the functionality is already present. I don't have any experience with programming in KDE, but I do with C++ programming, so I'm going to try to create a patch after finding my way in the code.
I have dived a bit in the code, and these are the things to adapt: - an extra member in SpamToolConfig to store the command to pipe through and so adapting the constructor to store the new member and accessor methods. - change createDummyConfig. - change readToolConfig to read in the new command. - change the AntiSpamWizard::accept method to add the PipeFilter when classifying as not Spam/as Ham. - add an extra field in kmail.antispamrc to store the new command. I don't know if I have to change something when adding a new command to the rc-file. Are there normally migration things, or do you detect if there is a field missing and do you add it then? Is it ok for me to start implementing this, or do I forget something?
Created attachment 14355 [details] Patch to remove spam markup when marking a message as not spam or ham. This patch adds an extra command to the filter "Classify as NOT spam", when generated by the anti-spam wizard. This involved adding one field to kmail.antispamrc and changing the wizard to cope with it. I named the field PipeCmdNoSpam but that can of course be changed. Please review it and comment on it, and if you like it, commit it since I don't have a svn account.
In principle, the patch looks quite good. However I'm not sure it will do what is intended. From what I've seen after a first glance it will remove the headers only when you mark a message manually as not spam. Doing so for all automatically checked messages which are not spam would require a bit more effort, i.e. an extra filter to remove the spam headers of non-spam messages before the filter which moves detected spam away.
It's only the intention to remove the spam markup if you mark it manually as not spam. If the spamfilter detects a message as ham, it can still be a false negative and maybe you want to see the score of the message and why it has been marked accordingly. KMail also shows a nice "graph" with the score and the report, which would be lost if you clear the headers. If spamassassin detects something as spam, it adds a lot of headers to it, so the body resulting mail you see is not the one that was intended. If it detects it as ham, you don't have those extra text in the body, so there is not really a point removing it.
> It's only the intention to remove the spam markup if you > mark it manually as not spam. Why don't you simply use: ExecCmdHam=spamassassin -d | sa-learn -L --ham --no-rebuild --single I haven't tried this special case, but AFAIK the pipe operator works. Can you give it a try? Such a change would be much easier than adding logic to the anti-spam wizard.
You can't pipe a message through sa-learn. sa-learn gets an email as argument, so your command doesn't work. And to remove the spam markup, it has to be piped through spamassassin -d.
Any news about committing this patch?
Am Montag, 30. Januar 2006 16:28 schrieb Jan Callewaert: > Any news about committing this patch? As there is no string change involved, feel free to commit it to the 3.5 branch (and port it to trunk). Andreas
I don't have commit access, so I guess somebody else should do this, or can I apply somewhere for commit access?
Created attachment 14466 [details] Patch to remove spam markup when marking a message as not spam or ham. Removed a forgotten todo
Created attachment 14467 [details] patch against kde trunk Patch of kde 3.5 ported to trunk. It should compile, but since I can't build kdelibs4_snapshot, I couldn't test it.
SVN commit 505000 by tilladam: Commit patch by Jan Callewaert <jan.callewaert@gmail.com> (with slight modifications to make it compile against 4.0) which makes the 'mark as ham' action run spamassassin -d to remove SA's verbose headers. Thanks, Jan. Andreas, did you want this in branch as well? CCMAIL: agungl@kde.org CCMAIL: 94577@bugs.kde.org M +20 -8 antispamwizard.cpp M +8 -4 antispamwizard.h M +6 -0 kmail.antispamrc --- trunk/KDE/kdepim/kmail/antispamwizard.cpp #504999:505000 @@ -421,7 +421,17 @@ classHamFilterActions->append( classHamFilterAction ); } } - KMSearchPattern* classHamFilterPattern = classHamFilter->pattern(); + for ( QList<SpamToolConfig>::iterator it = mToolList.begin(); + it != mToolList.end(); ++it ) { + if ( mInfoPage->isProgramSelected( (*it).getVisibleName() ) + && (*it).useBayesFilter() && !(*it).isDetectionOnly() ) + { + KMFilterAction* classHamFilterAction = dict.value( "filter app" )->create(); + classHamFilterAction->argsFromString( (*it).getNoSpamCmd() ); + classHamFilterActions->append( classHamFilterAction ); + } + } + KMSearchPattern* classHamFilterPattern = classHamFilter->pattern(); if ( replaceExistingFilters ) classHamFilterPattern->setName( i18n( "Classify as NOT spam" ) ); else @@ -654,15 +664,15 @@ AntiSpamWizard::SpamToolConfig::SpamToolConfig( QString toolId, int configVersion, int prio, QString name, QString exec, QString url, QString filter, QString detection, QString spam, QString ham, - QString header, QString pattern, QString pattern2, QString serverPattern, - bool detectionOnly, bool regExp, bool bayesFilter, bool tristateDetection, - WizardMode type ) + QString noSpam, QString header, QString pattern, QString pattern2, + QString serverPattern, bool detectionOnly, bool regExp, bool bayesFilter, + bool tristateDetection, WizardMode type ) : mId( toolId ), mVersion( configVersion ), mPrio( prio ), mVisibleName( name ), mExecutable( exec ), mWhatsThisText( url ), mFilterName( filter ), mDetectCmd( detection ), mSpamCmd( spam ), - mHamCmd( ham ), mDetectionHeader( header ), mDetectionPattern( pattern ), - mDetectionPattern2( pattern2 ), mServerPattern( serverPattern ), - mDetectionOnly( detectionOnly ), + mHamCmd( ham ), mNoSpamCmd( noSpam ), mDetectionHeader( header ), + mDetectionPattern( pattern ), mDetectionPattern2( pattern2 ), + mServerPattern( serverPattern ), mDetectionOnly( detectionOnly ), mUseRegExp( regExp ), mSupportsBayesFilter( bayesFilter ), mSupportsUnsure( tristateDetection ), mType( type ) { @@ -748,6 +758,7 @@ QString detectCmd = configGroup.readEntry( "PipeCmdDetect" ); QString spamCmd = configGroup.readEntry( "ExecCmdSpam" ); QString hamCmd = configGroup.readEntry( "ExecCmdHam" ); + QString noSpamCmd = configGroup.readEntry( "PipeCmdNoSpam" ); QString header = configGroup.readEntry( "DetectionHeader" ); QString pattern = configGroup.readEntry( "DetectionPattern" ); QString pattern2 = configGroup.readEntry( "DetectionPattern2" ); @@ -757,7 +768,7 @@ bool supportsBayes = configGroup.readEntry( "SupportsBayes", false ); bool supportsUnsure = configGroup.readEntry( "SupportsUnsure", false ); return SpamToolConfig( id, version, prio, name, executable, url, - filterName, detectCmd, spamCmd, hamCmd, + filterName, detectCmd, spamCmd, hamCmd, noSpamCmd, header, pattern, pattern2, serverPattern, detectionOnly, useRegExp, supportsBayes, supportsUnsure, mMode ); @@ -772,6 +783,7 @@ "spamassassin -L", "sa-learn -L --spam --no-rebuild --single", "sa-learn -L --ham --no-rebuild --single", + "spamassassin -d", "X-Spam-Flag", "yes", "", "", false, false, true, false, AntiSpam ); } --- trunk/KDE/kdepim/kmail/antispamwizard.h #504999:505000 @@ -91,7 +91,8 @@ PipeCmdDetect=spamassassin -L ExecCmdSpam=sa-learn --spam --no-rebuild --single ExecCmdHam=sa-learn --ham --no-rebuild --single - DetectionHeader=X-Spam-Flag + PipeCmdNoSpam=spamassassin -d + DetectionHeader=X-Spam-Flag DetectionPattern=yes DetectionPattern2= DetectionOnly=0 @@ -139,8 +140,8 @@ SpamToolConfig( QString toolId, int configVersion, int prio, QString name, QString exec, QString url, QString filter, QString detection, QString spam, QString ham, - QString header, QString pattern, QString pattern2, - QString serverPattern, + QString noSpam, QString header, QString pattern, + QString pattern2, QString serverPattern, bool detectionOnly, bool regExp, bool bayesFilter, bool tristateDetection, WizardMode type ); @@ -154,6 +155,7 @@ QString getDetectCmd() const { return mDetectCmd; } QString getSpamCmd() const { return mSpamCmd; } QString getHamCmd() const { return mHamCmd; } + QString getNoSpamCmd() const { return mNoSpamCmd; } QString getDetectionHeader() const { return mDetectionHeader; } QString getDetectionPattern() const { return mDetectionPattern; } QString getDetectionPattern2() const { return mDetectionPattern2; } @@ -190,7 +192,9 @@ QString mSpamCmd; // pipe through cmd to let the tool learn a ham message QString mHamCmd; - // by which header are messages marked as spam + // pipe through cmd to let the tool delete the spam markup + QString mNoSpamCmd; + // by which header are messages marked as spam QString mDetectionHeader; // what header pattern is used to mark spam messages QString mDetectionPattern; --- trunk/KDE/kdepim/kmail/kmail.antispamrc #504999:505000 @@ -12,6 +12,7 @@ PipeCmdDetect=spamassassin -L ExecCmdSpam=sa-learn -L --spam --no-rebuild --single ExecCmdHam=sa-learn -L --ham --no-rebuild --single +PipeCmdNoSpam=spamassassin -d DetectionHeader=X-Spam-Flag DetectionPattern=yes DetectionPattern2= @@ -36,6 +37,7 @@ PipeCmdDetect=bogofilter -p -e -u ExecCmdSpam=bogofilter -N -s ExecCmdHam=bogofilter -S -n +PipeCmdNoSpam= DetectionHeader=X-Bogosity DetectionPattern=(yes)|(spam\b) DetectionPattern2= @@ -60,6 +62,7 @@ PipeCmdDetect=$HOME/.annoyance-filter/annoyance-filter --fread $HOME/.annoyance-filter/FastDict.bin --phrasemin 1 --phrasemax 2 --transcript - --test - ExecCmdSpam=$HOME/.annoyance-filter/annoyance-filter --read $HOME/.annoyance-filter/Dict.bin --phrasemin 1 --phrasemax 2 --junk - --prune --write $HOME/.annoyance-filter/Dict.bin --fwrite $HOME/.annoyance-filter/FastDict.bin ExecCmdHam=$HOME/.annoyance-filter/annoyance-filter --read $HOME/.annoyance-filter/Dict.bin --phrasemin 1 --phrasemax 2 --mail - --prune --write $HOME/.annoyance-filter/Dict.bin --fwrite $HOME/.annoyance-filter/FastDict.bin +PipeCmdNoSpam= DetectionHeader=X-Annoyance-Filter-Classification DetectionPattern=Junk DetectionPattern2= @@ -79,6 +82,7 @@ PipeCmdDetect= ExecCmdSpam= ExecCmdHam= +PipeCmdNoSpam= DetectionHeader=X-GMX-Antispam DetectionPattern=^[2345] DetectionPattern2= @@ -126,6 +130,7 @@ PipeCmdDetect=spamc ExecCmdSpam=sa-learn -L --spam --no-rebuild --single ExecCmdHam=sa-learn -L --ham --no-rebuild --single +PipeCmdNoSpam=spamassassin -d DetectionHeader=X-Spam-Flag DetectionPattern=yes DetectionPattern2= @@ -150,6 +155,7 @@ PipeCmdDetect=spamassassin -L ExecCmdSpam=sa-learn -L --spam --no-sync ExecCmdHam=sa-learn -L --ham --no-sync +PipeCmdNoSpam=spamassassin -d DetectionHeader=X-Spam-Flag DetectionPattern=yes DetectionPattern2=
If this patch has been applied, I suppose this bug can be closed. As far as I can see, I cannot do it, so I would like to ask somebody which has the appropiate rights to close it.
Closing because of comment #16.
This patch is present in HEAD but not in 3.5.7 and 3.5.8 releases. Why?