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

List:       kmail-devel
Subject:    [Bug 26021] kmail filter enhancement request matching address book
From:       mail () joerg-brenninkmeyer ! de
Date:       2004-03-01 2:48:50
Message-ID: 20040301024850.6941.qmail () ktown ! kde ! org
[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=26021      




------- Additional Comments From mail joerg-brenninkmeyer de  2004-03-01 03:48 \
------- There is a bug in my script (see last comment) that Jochen Puchalla \
fortunately informed me about. In the "echo $line" commands, I forgot to put $line \
into quotes, so if there are special characters like * in incoming mails, they will \
be interpreted by the shell. With *, this makes your home directory appear in mails \
from other people - not quite a nice experience. So if you're using my script, please \
correct this by either replacing the two lines with echo $line
by
echo "$line"
or just copy and paste the new version below. I included spaces instead of tabs this \
time, so maybe it will even be indented in the comment view ;-).


#!/bin/bash

IFS="
"

KABC_VCF_PATH="$HOME/.kde/share/apps/kabc/std.vcf"
KMAILRC_PATH="$HOME/.kde/share/config/kmailrc"
TAGNAME="X-In-Addressbook-Or-Recent:"

fromHeaderFound=0

while read line
do
  echo "$line"
  if [[ $fromHeaderFound = "0" ]]; then
      if [ ${line:0:6} = "From: " ]; then
          # Check for e-mail address in < >
          emailAddress=`expr "$line" : '.*<\(.*\)>.*'`
          # If not found, check for standalone e-mail address
          if [ ${#emailAddress} = "0" ]; then
              emailAddress=`expr "$line" : 'From:\ \(.*\)'`
          fi
          # Only add tag if e-mail address could be read
          if [ ! ${#emailAddress} = "0" ]; then
              # Check for e-mail address in address book
              grep -i "$emailAddress" "$KABC_VCF_PATH" > /dev/null
              if  [ $? = "0" ]; then
                  echo "${TAGNAME} Yes"
              else
                  # Check for e-mail address in recent list
                  grep -i "$emailAddress" "$KMAILRC_PATH" > /dev/null
                  if  [ $? = "0" ]; then
                      echo "${TAGNAME} Yes"
                  else
                      echo "${TAGNAME} No"
                  fi
              fi
          fi
          fromHeaderFound="1"
          # Only write next line if it is not an old X-Tag
          read line
          if [ ! ${line:0:${#TAGNAME}} = "${TAGNAME}" ]; then
              echo "$line"
          fi
      fi
  fi
done
_______________________________________________
KMail developers mailing list
KMail-devel@kde.org
https://mail.kde.org/mailman/listinfo/kmail-devel


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

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