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

List:       kmail-devel
Subject:    [Bug 59053] New: email REappears unaltered after filtering through
From:       Danny Luker <dannyl () ilovejesus ! com>
Date:       2003-05-27 20:00:25
[Download RAW message or body]

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
     
http://bugs.kde.org/show_bug.cgi?id=59053     
           Summary: email REappears unaltered after filtering through the
                    "pipe through" action
           Product: kmail
           Version: 1.5
          Platform: Mandrake RPMs
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: general
        AssignedTo: kmail@kde.org
        ReportedBy: dannyl@ilovejesus.com


Version:           1.5 (using KDE 3.1.0)
Installed from:    Mandrake Linux Cooker i586 - Cooker
Compiler:          gcc version 3.2.2 (Mandrake Linux 9.1 3.2.2-3mdk)
OS:          Linux (i586) release 2.4.21-0.13mdk

There appears to be a bug in Kmail filtering engine which allows a message that has \
been modified by using the "pipe through" action to revert to the previously \
unfiltered (and unaltered) message after a few moments (minutes).

The following are specifics:

My machine is a Compaq Presario 5150 with 350Mhz K6/2 with 390MB ram.
Distribution is Mandrake 9.1 with Kmail 1.5 (Using KDE 3.1.0)

I have set up multiple filters for attacking the SPAM problem which follow this basic \
pattern ...

============ BEGIN Filter Name BL-5 ===================
Filter Criteria
        * Match any of the following
                <message> matches regular expr.    ----->  regex (   i.e.
                                 [pP][^a-zA-Z]*[oO0][^a-zA-Z]*[rR][^a-zA-Z]*[nN]    )
                (usually just one regex per filtering to simplify trouble shooting)

Filter Action
        move to folder ---> trash
        add header ---> X-SPAMfilter --->BL-5:Porn  <--- Aids troubleshooting
        pipe through ---> /usr/local/bin/SPAM-mangle.sh -f .filter-testing - 

Advanced Options
        Apply this filter _x_ to incoming messages ___ to sent messages _x_ on manual \
filtering  _x_ If this filter matches, stop processing her
============ END Filter Name BL-5 =====================

The source code for my /usr/local/bin/SPAM-mangle.sh script appearing in the above \
"pipe through" action is included at the end of this message for completeness.  \
Please no laughing outloud ... this is my first BASH script and I'm a simple power \
plant operator ... not a programmer or IT guy ;-)  All right ... alittle laughter \
never hurt anyone ... so go ahead.

Any way ... back to the problem ....

> From the above my intent was to do the following ...
        1) Look for SPAM (in this case contain the word porn in its various
            incarnations) and when found do the following ...
                1a) move it to "trash" folder
                1b) add a header telling me which filter clobbered it for reference
                        during troubleshooting
                1c) pass it through my SPAM-mangle script.
        2) SPAM-mangle returns a message to Kmail altered and in the trash folder.

While testing this I would receive a SPAM and it all seemed to work well.
The message appeared in the trash folder mangled beyond recognition.  However,
after a few moments _/before my very eyes and to my astonishment!/_ the original \
message appeared replacing its formerly mangled self completely untouched i.e. not \
even the X-SPAMfilter header appeared in the source.  It was as if the re-incarnated \
message was only touched by the "move to folder ---> trash" action. I'm not sure how \
long this took, maybe a minute or two, seemed to vary abit).

I have worked around the problem (so far so good) by reordering my action list to \
place the "move to folder ---> trash" action as the last action in the list.  I am \
thinking that it was probably the buggy culprit (if not something in my own script \
but it is pretty simple).  This seems to have fixed the problem.

My application is just to get rid of all the foul SPAM but I can imagine in another \
context this problem could have more serious consequences.

Anyway ... I hope this is of value to you.

Thanks for all your hard and excellent work.  I really love your products!  I brag \
about them all the time to my Winblows bound friends!

Have a great day!
Danny Luker



============ BEGIN /usr/local/bin/SPAM-mangle.sh ==========
#!/bin/bash

#  Pass a -t to place in test mode. Returns message untouched
#
#  Pass -f (file) to be used to hold suspect emails in case wrongly filtered.
#    the argument should me a legal file name. If the file exists it
#    will be appended to.  Otherwise it will be created in the user
#    home director and appended to there after.

TESTMODE="OFF"
STRING=""
EMAIL=""
FROM=""
OPT=""
FILENAME="Unknown"


while getopts "tf:" OPT;
        do
                case $OPT in
                        t)
                                TESTMODE="ON" ;;
                        f)
                                FILENAME=$OPTARG ;;
                esac
done

# Getting the message either from the command line (testing purposes)
# or from stdin if - is passed as the last argument.
let pos=$#-1
shift $pos
EMAIL=$1

if [ $EMAIL = "-" ]
then
        EMAIL=`cat /dev/stdin`
fi




if [ "ON" = $TESTMODE ]
then    # TEST mode is on so return the message unscathed ....
        echo "$EMAIL"

else   # mangle it!
        # If a -f argument was passed us it to store the email
        #   for troubleshooting purposes.
        if [ $FILENAME != "Unknown" ]
        then
                echo "$EMAIL" >> ~/$FILENAME
        fi


        #Now let's send a message back the mail client to replace
        #    the one we do not want to see.
        FROM=`echo "$EMAIL" | grep From: - | cut -d: -f2`
        FILTER=`echo "$EMAIL" | grep X-SPAMfilter - | cut -d: -f2`

        echo "Date: `date +"%a, %d %b %Y %T %z"`"
        echo "From: $FROM escorted by SPAM-mangle.sh"
        echo "To: Whom it may concern"
        echo "Subject: This was SPAM and I have destroyed it!!"
        echo ""
        echo "This message was folded, spindled and mutilated"
        echo "by your filter due to unsavory or otherwise"
        echo "undesirable content."
        echo " "
        echo "Reference: $FILTER"

fi
============ END /usr/local/bin/SPAM-mangle.sh ===========
_______________________________________________
KMail Developers mailing list
kmail@mail.kde.org
http://mail.kde.org/mailman/listinfo/kmail


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

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