diff --git a/sieve/examples/sieve_examples.sieve b/sieve/examples/sieve_examples.sieve index 639810783e98b0c832772eb2a9bc387a5940ae05..6e7ca1780a9c9ade89215a113e90eee052514cc2 100644 --- a/sieve/examples/sieve_examples.sieve +++ b/sieve/examples/sieve_examples.sieve @@ -1,3 +1,7 @@ +# Example Sieve Script +# Author: unknown +# URL: http://wiki.fastmail.fm/index.php?title=MoreSieveExamples + require ["fileinto", "reject"]; ###BYPASSES### diff --git a/sieve/examples/stephan.sieve b/sieve/examples/stephan.sieve deleted file mode 100644 index 8a814db69f6cd772ebd7625a906a7eb936bd2ada..0000000000000000000000000000000000000000 --- a/sieve/examples/stephan.sieve +++ /dev/null @@ -1,252 +0,0 @@ -# Sieve filter - -require "fileinto"; - -if header :contains "X-RenameIT-MailScanner-SpamScore" "sssss" { - redirect "spam@drunksnipers.com"; - stop; -} - -if header :contains "X-Mailing-List" "linux-kernel@vger.kernel.org" { - fileinto "inbox.INBOX.Kernel.linux-kernel"; - stop; -} - -if header :contains "List-Id" "mspgcc-users.lists.sourceforge.net" { - fileinto "inbox.INBOX.Embedded Systems.mspgcc"; - stop; -} - -if header :contains "List-Id" "ietf-imapext.imc.org" { - fileinto "inbox.INBOX.Internet Standards Mailinglists.ietf-imapext"; - stop; -} - -if header :contains "List-Id" "ietf-mta-filters.imc.org" { - fileinto "inbox.INBOX.Internet Standards Mailinglists.ietf-mta-filters"; - stop; -} - -if header :contains "List-Id" "imap-protocol.u.washington.edu" { - fileinto "inbox.INBOX.Internet Standards Mailinglists.imap-protocol"; - stop; -} - -if header :contains "List-Id" "lemonade.ietf.org" { - fileinto "inbox.INBOX.Internet Standards Mailinglists.lemonade"; - stop; -} - -if header :contains "List-Id" "exim-users.exim.org" { - fileinto "inbox.INBOX.Software Mailinglists.exim-users"; - stop; -} - -if header :contains "List-Id" "exim-dev.exim.org" { - fileinto "inbox.INBOX.Software Mailinglists.exim-dev"; - stop; -} - -if header :contains "List-Id" "courier-imap.lists.sourceforge.net" { - fileinto "inbox.INBOX.Software Mailinglists.courier-imap"; - stop; -} - -if header :contains "List-Id" "dovecot.dovecot.org" { - fileinto "inbox.INBOX.Software Mailinglists.dovecot"; - stop; -} - -if header :contains "List-Id" "dovecot-cvs.dovecot.org" { - fileinto "inbox.INBOX.Software Mailinglists.dovecot-cvs"; - stop; -} - -if header :contains "List-Id" "mailman-developers.python.org" { - fileinto "inbox.INBOX.Software Mailinglists.mailman-dev"; - stop; -} - -if header :contains "List-Id" "mailman3-dev.python.org" { - fileinto "inbox.INBOX.Software Mailinglists.mailman3-dev"; - stop; -} - -if header :contains "List-Id" "mailscanner.lists.mailscanner.info" { - fileinto "inbox.INBOX.Software Mailinglists.mailscanner"; - stop; -} - -if header :contains "List-Id" "openvpn-devel.lists.sourceforge.net" { - fileinto "inbox.INBOX.Software Mailinglists.openvpn-devel"; - stop; -} - -if header :contains "List-Id" "sare-users.maddoc.net" { - fileinto "inbox.INBOX.Software Mailinglists.sare-users"; - stop; -} - -if header :contains "List-Id" "twisted-python.twistedmatrix.com" { - fileinto "inbox.INBOX.Software Mailinglists.twisted-python"; - stop; -} - -if header :contains "List-Id" "vtun-devel.lists.sourceforge.net" { - fileinto "inbox.INBOX.Software Mailinglists.vtun-devel"; - stop; -} - -if header :contains "List-Id" "users.spamassassin.apache.org" { - fileinto "inbox.INBOX.Software Mailinglists.spamassassin-users"; - stop; -} - -if header :contains "List-Id" "dev.spamassassin.apache.org" { - fileinto "inbox.INBOX.Software Mailinglists.spamassassin-dev"; - stop; -} - -if header :contains "List-Id" "kde-pim.kde.org" { - fileinto "inbox.INBOX.Software Mailinglists.kde-pim"; - stop; -} - -if header :contains "List-Id" "kde-perl.kde.org" { - fileinto "inbox.INBOX.Software Mailinglists.kde-perl"; - stop; -} - -if header :contains "List-Post" "ut2004@icculus.org" { - fileinto "inbox.INBOX.Unreal Tournament.ut2004@icculus"; - stop; -} - -if header :contains "List-Id" "ut2004servers.udn.epicgames.com" { - fileinto "inbox.INBOX.Unreal Tournament.ut2004-servers"; - stop; -} - -if anyof ( - header :contains "To" "beheer@vestingbar.", - header :contains "Cc" "beheer@vestingbar.", - header :contains "To" "-admin@vestingbar.", - header :contains "To" "-owner@vestingbar." ) { - fileinto "inbox.INBOX.Vestingbar.beheer@vestingbar"; - stop; -} - -if anyof ( - header :contains "To" "nico@vestingbar.", - header :contains "Cc" "nico@vestingbar.", - header :contains "To" "flowview@vestingbar.", - header :contains "Cc" "flowview@vestingbar.", - header :contains "List-Id" "td.vestingbar.nl", - header :contains "List-Id" "all.vestingbar.nl" ) { - fileinto "inbox.INBOX.Vestingbar.nico@vestingbar"; - stop; -} - -if header :contains "To" "abuse@" { - fileinto "inbox.INBOX.System Admin.abuse"; - stop; -} - -if header :contains "To" "spammaster@" { - fileinto "inbox.INBOX.System Admin.spammaster"; - stop; -} - -if header :contains "To" "virusmaster@" { - fileinto "inbox.INBOX.System Admin.virusmaster"; - stop; -} - -if header :contains "To" "postmaster@" { - fileinto "inbox.INBOX.System Admin.postmaster"; - stop; -} - -if header :contains "To" "postmaster@" { - fileinto "inbox.INBOX.System Admin.webmaster"; - stop; -} - -if anyof( - header :contains "To" "@cola.", - header :contains "Cc" "@cola." ) { - - fileinto "inbox.INBOX.Servers.cola"; - stop; -} - -if anyof( - header :contains "To" "@sinas.", - header :contains "Cc" "@sinas." ) { - - fileinto "inbox.INBOX.Servers.sinas"; - stop; -} - -if anyof( - header :contains "To" "@sevenup.", - header :contains "Cc" "@sevenup." ) { - - fileinto "inbox.INBOX.Servers.sevenup"; - stop; -} - -if anyof( - header :contains "To" "@taksi.", - header :contains "Cc" "@taksi." ) { - - fileinto "inbox.INBOX.Servers.taksi"; - stop; -} - -if anyof( - header :contains "To" "@rivella.", - header :contains "Cc" "@rivella." ) { - - fileinto "inbox.INBOX.Servers.rivella"; - stop; -} - -if anyof( - header :contains "To" "@klara.", - header :contains "Cc" "@klara.", - header :contains "From" "logcheck@klara." ) { - - fileinto "inbox.INBOX.Servers.klara"; - stop; -} - -if anyof( - header :contains "To" "root@vestingbar.", - header :contains "To" "mail@vestingbar.", - header :contains "Cc" "root@vestingber." ) { - - fileinto "inbox.INBOX.Servers.vestingbar"; - stop; -} - -# Final rules -if anyof( - header :contains "To" "stephan@rename-it.nl", - header :contains "Cc" "stephan@rename-it.nl", - header :contains "To" "sirius@rename-it.nl", - header :contains "Cc" "sirius@rename-it.nl" ) { - - fileinto "inbox.INBOX.Accounts.stephan@rename-it"; - stop; -} - -if anyof( - header :contains "To" "stephan@drunksnipers.com", - header :contains "Cc" "stephan@drunksnipers.com", - header :contains "To" "sirius@drunksnipers.com", - header :contains "Cc" "sirius@drunksnipers.com" ) { - - fileinto "inbox.INBOX.Accounts.sirius@drunksnipers"; - stop; -} diff --git a/sieve/examples/unparsed-elvey.sieve b/sieve/examples/unparsed-elvey.sieve deleted file mode 100644 index d999c0256af0ff6981cd63ebbfcbc49fe3ea0b58..0000000000000000000000000000000000000000 --- a/sieve/examples/unparsed-elvey.sieve +++ /dev/null @@ -1,305 +0,0 @@ -require [ - "fileinto", - "reject", - "vacation", - "envelope", - "regex" ]; -if header :contains "subject" [ - "un eject", - "lastname.com/spamoff.htm agreed to" ] { - keep; -} -elsif header :contains "subject" [ - "ADV:", - "bounceme", - "2002 Gov Grants", - "ADV:ADLT", - "ADV-ADULT", - "ADULT ADVERTISEMENT" ] { - reject text: - Hello. The server content filter/spam detector I use has bounced your message. It appears to be spam. - - I do not accept spam/UCE (Unsolicited Commercial Email). - -Please ask me how to bypass this filter if your email is not UCE. In that case, I am sorry about this -highly unusual error. The filter is >99% accurate. - - (This is an automated message; I will not be aware that your message did not get through if I do not hear from you again.) - - -Firstname - - (P.S. You may also override the filter if you accept the terms at http://www.lastname.com/spamoff.htm, - by including "lastname.com/spamoff.htm agreed to." in the subject.) - -. -; -} -elsif size :over 10485760 { - reject text: - Message NOT delivered! - This system normally accepts email that is less than 10MB in size, because that is how I configured it. - You may want to put your file on a server and send me the URL. - Or, you may request override permission and/or unreject instructions via another (smaller) email. -Sorry for the inconvenience. - Thanks, -.... Firstname - (This is an automated message; I will not be aware that your message did not get through if I do not hear from you again.) - - Unsolicited advertising sent to this E-Mail address is expressly prohibited - under USC Title 47, Section 227. Violators are subject to charge of up to - $1,500 per incident or treble actual costs, whichever is greater. - -. -; -} -elsif header :contains "From" "Firstname@lastname.com" { - keep; -} -elsif header :contains [ - "Sender", - "X-Sender", - "Mailing-List", - "Delivered-To", - "List-Post", - "Subject", - "To", - "Cc", - "From", - "Reply-to", - "Received" ] "burningman" { - fileinto "INBOX.DaBurn"; -} -elsif header :contains [ - "Subject", - "From", - "Received" ] [ - "E*TRADE", - "Datek", - "TD Waterhouse", - "NetBank" ] { - fileinto "INBOX.finances.status"; -} -elsif header :contains "subject" "[pacbell" { - fileinto "INBOX.pacbell.dslreports"; -} -elsif header :contains "From" [ - "owner-te-wg ", - "te-wg ", - "iana.org" ] { - fileinto "INBOX.lst.IETF"; -} -elsif header :contains [ - "Mailing-List", - "Subject", - "From", - "Received" ] [ - "Red Hat", - "Double Funk Crunch", - "@economist.com", - "Open Magazine", - "@nytimes.com", - "mottimorell", - "Harrow Technology Report" ] { - fileinto "INBOX.lst.interesting"; -} -elsif header :contains [ - "Mailing-List", - "Subject", - "From", - "Received", - "X-LinkName" ] [ - "DJDragonfly", - "Ebates", - "Webmonkey", - "DHJ8091@aol.com", - "Expedia Fare Tracker", - "SoulShine", - "Martel and Nabiel", - "[ecc]" ] { - fileinto "INBOX.lst.lame"; -} -elsif header :contains [ - "Subject", - "From", - "To" ] [ - "guru.com", - "monster.com", - "hotjobs", - "dice.com", - "linkify.com" ] { - fileinto "INBOX.lst.jobs"; -} -elsif header :contains "subject" "[yaba" { - fileinto "INBOX.rec.yaba"; -} -elsif header :contains [ - "to", - "cc" ] "scalable@" { - fileinto "INBOX.lst.scalable"; -} -elsif header :contains [ - "Sender", - "To", - "Return-Path", - "Received" ] "NTBUGTRAQ@listserv.ntbugtraq.com" { - fileinto "INBOX.lst.bugtraq"; -} -elsif header :contains "subject" "Wired" { - fileinto "INBOX.lst.wired"; -} -elsif anyof ( - header :contains "From" [ - "postmaster", - "daemon", - "abuse" ], - header :contains "Subject" [ - "warning:", - "returned mail", - "failure notice", - "undelivered mail" ] ) { - keep; -} -elsif anyof header :contains "From" "and here I put a whitelist of pretty much all the email addresses in my address book - it's several pages..." { - fileinto "INBOX.white"; -} -elsif anyof ( - envelope :all :is [ - "To", - "CC", - "BCC" ] "Firstname.lastname@fastmail.fm", - header :matches "X-Spam-score" [ - "9.?", - "10.?", - "9", - "10", - "11.?", - "12.?", - "13.?", - "14.?", - "11", - "12", - "13", - "14", - "15.?", - "16.?", - "17.?", - "18.?", - "19.?", - "15", - "16", - "17", - "18", - "19", - "2?.?", - "2?", - "3?.?", - "3?", - "40" ] ) { - reject text: - Hello. The server content filter/spam detector I use has bounced your message. It appears to be spam. - - I do not accept spam/UCE (Unsolicited Commercial Email). - -Please ask me how to bypass this filter if your email is not UCE. In that case, I am sorry about this -highly unusual error. The filter is >99% accurate. - - (This is an automated message; I will not be aware that your message did not get through if I do not hear from you again.) - - -Firstname - - (P.S. You may also override the filter if you accept the terms at http://www.lastname.com/spamoff.htm, - by including "lastname.com/spamoff.htm agreed to." in the subject.) - -. -; -} -elsif header :matches "X-Spam" [ - "spam", - "high" ] { - if header :matches "X-Spam-score" [ - "5.?", - "6.?", - "5", - "6" ] { - fileinto "INBOX.Spam.5-7"; - } - elsif header :matches "X-Spam-score" [ - "7.?", - "8.?", - "7", - "8" ] { - fileinto "INBOX.Spam.7-9"; - } -} -elsif header :contains [ - "Content-Type", - "Subject" ] [ - "ks_c_5601-1987", - "euc_kr", - "euc-kr" ] { - fileinto "Inbox.Spam.kr"; -} -elsif header :contains "Received" "yale.edu" { - fileinto "INBOX.Yale"; -} -elsif anyof ( - header :contains "Subject" [ - "HR 1910", - "viagra", - "MLM", - " ", - " " ], - not exists [ - "From", - "Date" ], - header :contains [ - "Sender", - "X-Sender", - "Mailing-List", - "X-Apparently-From", - "X-Version", - "X-Sender-IP", - "Received", - "Return-Path", - "Delivered-To", - "List-Post", - "Date", - "Subject", - "To", - "Cc", - "From", - "Reply-to", - "X-AntiAbuse", - "Content-Type", - "Received", - "X-LinkName" ] [ - "btamail.net.cn", - "@arabia.com" ] ) { - fileinto "INBOX.GreyMail"; -} -elsif header :contains [ - "Precedence", - "Priority", - "X-Priority", - "Mailing-List", - "Subject", - "From", - "Received", - "X-LinkName" ] [ - "Bulk", - "Newsletter" ] { - fileinto "INBOX.Bulk Precedence"; -} -elsif header :contains [ - "to", - "cc", - "Received" ] [ - "IT@lastname.com", - "mail.freeservers.com" ] { - fileinto "INBOX.lastname.IT"; -} -elsif header :contains [ - "To", - "CC" ] "Firstname@lastname.com" { - fileinto "INBOX.lastname.non-BCC"; -} diff --git a/src/lib-sieve/sieve-code.h b/src/lib-sieve/sieve-code.h index 56389a84d5dd575f804138f4b56ff78ff9189cac..01ac8ef34e78c9aa4946d96204c4bc3f6919ff8e 100644 --- a/src/lib-sieve/sieve-code.h +++ b/src/lib-sieve/sieve-code.h @@ -32,15 +32,6 @@ enum sieve_core_operation { extern const struct sieve_opcode *sieve_opcodes[]; extern const unsigned int sieve_opcode_count; -/* Operand: argument to and opcode */ -struct sieve_operand { - /* Code generator */ - bool (*emit)(struct sieve_generator *generator, struct sieve_ast_argument *arg); - - /* Interpreter */ - bool (*dump)(struct sieve_interpreter *interpreter); -}; - enum sieve_core_operand { SIEVE_OPERAND_NUMBER, SIEVE_OPERAND_STRING, @@ -50,6 +41,19 @@ enum sieve_core_operand { SIEVE_OPERAND_ADDR_PART }; +/* Operand: argument to and opcode */ +struct sieve_operand { + /* Interpreter */ + bool (*dump)(struct sieve_interpreter *interpreter); +}; + +struct sieve_operand_string { + struct sieve_operand operand; + + void (*emit)(struct sieve_generator *generator, string_t *str); + bool (*read)(struct sieve_interpreter *interpreter, string_t **str) +}; + void sieve_operand_number_emit(struct sieve_generator *generator, sieve_size_t number); void sieve_operand_string_emit(struct sieve_generator *generator, string_t *str); void sieve_operand_stringlist_emit_start