Commit 831f9871 authored by Laurent Montel's avatar Laurent Montel 😁

Add autotest for scriptparsing before porting it to QXmlStreamWriter

parent d3cbaf6c
......@@ -15,6 +15,7 @@ if(BUILD_TESTING)
add_subdirectory(editor/autotests)
add_subdirectory(autocreatescripts/tests)
add_subdirectory(scriptsparsing/tests)
add_subdirectory(scriptsparsing/autotests)
add_subdirectory(vacation/autotests)
add_subdirectory(sievescriptdebugger/autotests)
add_subdirectory(sievescriptdebugger/tests)
......
add_definitions( -DXMLPRINTINGSCRIPTBUILDER_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" )
macro(add_sieveeditor_xmlprintingscriptbuilding _source _extrasource)
set(_test ${_source} ${_extrasource})
get_filename_component(_name ${_source} NAME_WE)
ecm_add_test(${_test}
TEST_NAME ${_name}
NAME_PREFIX "sieveeditor-xmlprintingscriptbuilding-"
LINK_LIBRARIES Qt5::Test Qt5::Xml KF5::I18n KF5::KSieveUi
)
endmacro()
add_sieveeditor_xmlprintingscriptbuilding(xmlprintingscriptbuildertest.cpp "" "")
<?xml version='1.0'?><script><control name="require"><str type="quoted">imapflags</str></control><crlf/><crlf/><comment type="hash">Script name: add flags </comment><crlf/><control name="if"><test name="size"><tag>under</tag><num>1</num><crlf/></test><block><crlf/><action name="addflag"><list><str type="quoted">\Deleted</str><str type="quoted">\Answered</str><str type="quoted">\Flagged</str></list></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "imapflags";
#Script name: add flags
if size :under 1
{
addflag [ "\\Deleted", "\\Answered", "\\Flagged" ];
}
<?xml version='1.0'?><script><action name="addheader"><str type="quoted">X-Sieve-Filtered</str><str type="quoted">kim@job.example.com</str></action><crlf/></script>
\ No newline at end of file
addheader "X-Sieve-Filtered" "kim@job.example.com";
<?xml version='1.0'?><script><control name="require"><str type="quoted">ihave</str></control><crlf/><control name="require"><str type="quoted">imapflags</str></control><crlf/><crlf/><comment type="hash">Script name: add-single-flag</comment><crlf/><control name="if"><test name="ihave"><str type="quoted">reject</str><crlf/></test><block><crlf/><action name="addflag"><list><str type="quoted">\Seen</str></list></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "ihave";
require "imapflags";
#Script name: add-single-flag
if ihave "reject"
{
addflag [ "\\Seen" ];
}
<?xml version='1.0'?><script><comment type="hash"> Sieve filter</comment><crlf/><comment type="hash"> Declare the extensions used by this script.</comment><comment/><control name="require"><list><str type="quoted">fileinto</str><str type="quoted">reject</str></list></control><crlf/><crlf/><comment type="hash"> Messages bigger than 100K will be rejected with an error message</comment><comment/><control name="if"><test name="size"><tag>over</tag><num quantifier="K">102400</num></test><block><crlf/><action name="reject"><str type="quoted">I'm sorry, I do not accept mail over 100kb in size.
Please upload larger files to a server and send me a link.
Thanks.</str></action><crlf/></block></control><crlf/><crlf/><comment type="hash"> Mails from a mailing list will be put into the folder "mailinglist" </comment><comment/><control name="elsif"><test name="address"><tag>is</tag><list><str type="quoted">From</str><str type="quoted">To</str></list><str type="quoted">mailinglist@blafasel.invalid</str></test><block><crlf/><action name="fileinto"><str type="quoted">INBOX.mailinglist</str></action><crlf/></block></control><crlf/><crlf/><comment type="hash"> Spam Rule: Message does not contain my address in To, CC or Bcc</comment><comment type="hash"> header, or subject is something with "money" or "Viagra".</comment><comment/><control name="elsif"><test name="anyof"><testlist><test name="not"><test name="address"><tag>all</tag><tag>contains</tag><list><str type="quoted">To</str><str type="quoted">Cc</str><str type="quoted">Bcc</str></list><str type="quoted">me@blafasel.invalid</str></test></test><crlf/><test name="header"><tag>matches</tag><str type="quoted">Subject</str><list><str type="quoted">*money*</str><str type="quoted">*Viagra*</str></list></test></testlist></test><block><crlf/><action name="fileinto"><str type="quoted">INBOX.spam</str></action><crlf/></block></control><crlf/><crlf/><comment type="hash"> Keep the rest.</comment><comment type="hash"> This is not necessary because there is a "implicit keep" Rule</comment><comment/><control name="else"><block><crlf/><action name="keep"></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
# Sieve filter
# Declare the extensions used by this script.
#
require ["fileinto", "reject"];
# Messages bigger than 100K will be rejected with an error message
#
if size :over 100K {
reject "I'm sorry, I do not accept mail over 100kb in size.
Please upload larger files to a server and send me a link.
Thanks.";
}
# Mails from a mailing list will be put into the folder "mailinglist"
#
elsif address :is ["From", "To"] "mailinglist@blafasel.invalid" {
fileinto "INBOX.mailinglist";
}
# Spam Rule: Message does not contain my address in To, CC or Bcc
# header, or subject is something with "money" or "Viagra".
#
elsif anyof (not address :all :contains ["To", "Cc", "Bcc"] "me@blafasel.invalid",
header :matches "Subject" ["*money*","*Viagra*"]) {
fileinto "INBOX.spam";
}
# Keep the rest.
# This is not necessary because there is a "implicit keep" Rule
#
else {
keep;
}
<?xml version='1.0'?><script><crlf/><control name="if"><test name="address"><tag>detail</tag><str type="quoted">to</str><str type="quoted">shopping</str></test><block><action name="fileinto"><str type="quoted">shoppingMania</str></action><action name="stop"></action></block></control><crlf/><comment type="hash">#### Send some of my mail to my brother.</comment><comment type="hash"> ':matches' is used for wildcard matches;</comment><comment type="hash"> *: zero or more characters</comment><comment type="hash"> ?: a single character</comment><comment type="hash"> This example matches 'Summer vacation photos' ,</comment><comment type="hash"> and also 'Istanbul vacation photo'</comment><crlf/><crlf/></script>
\ No newline at end of file
if address :detail "to" "shopping" { fileinto "shoppingMania"; stop; }
##### Send some of my mail to my brother.
# ':matches' is used for wildcard matches;
# *: zero or more characters
# ?: a single character
# This example matches 'Summer vacation photos' ,
# and also 'Istanbul vacation photo'
<?xml version='1.0'?><script><comment type="hash"> rule:[Gerrit CI Success]</comment><control name="if"><test name="allof"><testlist><test name="exists"><str type="quoted">X-Gerrit-Commit</str></test><test name="not"><test name="body"><tag>text</tag><tag>contains</tag><list><str type="quoted">WARNINGS</str><str type="quoted">FAILURE</str></list></test></test><test name="header"><tag>contains</tag><str type="quoted">from</str><str type="quoted">Continuous Integration (Code Review)</str></test></testlist></test><crlf/><block><crlf/><action name="setflag"><str type="quoted">\Seen</str></action><crlf/><action name="fileinto"><str type="quoted">INBOX/Trash</str></action><crlf/><action name="stop"></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
# rule:[Gerrit CI Success]
if allof (exists "X-Gerrit-Commit", not body :text :contains ["WARNINGS","FAILURE"], header :contains "from" "Continuous Integration (Code Review)")
{
setflag "\\Seen";
fileinto "INBOX/Trash";
stop;
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">foreverypart</str></control><crlf/><crlf/><comment type="hash">Script name: break</comment><crlf/><control name="if"><test name="true"></test><block><crlf/><control name="break"><tag>name</tag><str type="quoted">optional name</str></control><crlf/><control name="break"></control><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "foreverypart";
#Script name: break
if true {
break :name "optional name";
break ;
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">subaddress</str></control><crlf/><control name="require"><str type="quoted">spamtest</str></control><crlf/><control name="require"><str type="quoted">relational</str></control><crlf/><control name="require"><str type="quoted">spamtestplus</str></control><crlf/><crlf/><comment type="hash">SCRIPTNAME: Script part 0</comment><comment type="hash"> Try to catch unsolicited email.</comment><control name="if"><test name="anyof"><testlist><test name="not"><test name="address"><tag>all</tag><tag>regex</tag><list><str type="quoted">to</str><str type="quoted">cc</str><str type="quoted">bcc</str></list><str type="quoted">me(\\+.*)?@company\\.com</str><crlf/></test></test><test name="spamtest"><tag>value</tag><str type="quoted">gt</str><tag>comparator</tag><str type="quoted">i;ascii-casemap</str><str type="quoted">0</str><crlf/></test></testlist></test><crlf/><block><crlf/><action name="discard"></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "subaddress";
require "spamtest";
require "relational";
require "spamtestplus";
#SCRIPTNAME: Script part 0
# Try to catch unsolicited email.
if anyof (not address :all :regex [ "to", "cc", "bcc" ] "me(\\\\+.*)?@company\\\\.com"
, spamtest :value "gt" :comparator "i;ascii-casemap" "0"
)
{
discard;
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">convert</str></control><crlf/><crlf/><comment type="hash">Script name: convert action </comment><crlf/><control name="if"><test name="true"></test><block><crlf/><action name="convert"><str type="quoted">image/png</str><str type="quoted">image/bmp</str><list><str type="quoted">pix-x=250</str><str type="quoted">pix-y=600</str></list></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "convert";
#Script name: convert action
if true {
convert "image/png" "image/bmp" ["pix-x=250","pix-y=600"];
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">editheader</str></control><crlf/><crlf/><comment type="hash">Script name: delete headers</comment><crlf/><control name="if"><test name="true"></test><block><crlf/><action name="deleteheader"><tag>matches</tag><str type="quoted">header-str</str><str type="quoted">header-value</str></action><crlf/><action name="deleteheader"><test name="not"><tag>is</tag><str type="quoted">header-str</str><str type="quoted">header-value</str></test></action><crlf/><action name="deleteheader"><test name="not"><tag>matches</tag><str/><str/></test></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
<?xml version='1.0'?><script><action name="deleteheader"><tag>index</tag><num>1</num><test name="not"><tag>regex</tag><str type="quoted">Delivered-To</str><str type="quoted">bob@example.com</str></test></action><crlf/></script>
\ No newline at end of file
deleteheader :index 1 not :regex "Delivered-To" "bob@example.com";
require "editheader";
#Script name: delete headers
if true {
deleteheader :matches "header-str" "header-value";
deleteheader not :is "header-str" "header-value";
deleteheader not :matches "" "";
}
<?xml version='1.0'?><script></script>
\ No newline at end of file
<?xml version='1.0'?><script><control name="require"><str type="quoted">ihave</str></control><crlf/><control name="require"><str type="quoted">enclose</str></control><crlf/><crlf/><comment type="hash">Script name: enclose</comment><crlf/><control name="if"><test name="ihave"><str type="quoted">enclosz</str><crlf/></test><block><crlf/><action name="enclose"><tag>subject</tag><str type="quoted">subject</str><tag>headers</tag><str type="quoted">headers</str><str type="multiline"> text</str></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "ihave";
require "enclose";
#Script name: enclose
if ihave "enclosz"
{
enclose :subject "subject" :headers "headers" text:
text
.
;
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">extracttext</str></control><crlf/><crlf/><comment type="hash">Script name: extract-text</comment><crlf/><control name="if"><test name="true"><crlf/></test><block><crlf/><action name="extracttext"><tag>first</tag><num>11</num><str type="quoted">voiture</str></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "extracttext";
#Script name: extract-text
if true
{
extracttext :first 11 "voiture";
}
<?xml version='1.0'?><script><control name="if"><test name="anyof"><testlist><test name="allof"><testlist><test name="header"><tag>regex</tag><str type="quoted">x-spam-status</str><str type="quoted">BAYES_[6-9][0-9]</str></test><crlf/><test name="not"><test name="header"><tag>contains</tag><str type="quoted">x-spam-flag</str><str type="quoted">yes</str></test></test></testlist></test><crlf/><test name="allof"><testlist><test name="header"><tag>regex</tag><str type="quoted">x-spam-status</str><str type="quoted">BAYES_[0-4][0-9]</str></test><crlf/><test name="header"><tag>contains</tag><str type="quoted">x-spam-flag</str><str type="quoted">yes</str></test></testlist></test></testlist></test><crlf/><block><crlf/><action name="fileinto"><str type="quoted">INBOX/trash</str></action><crlf/><action name="stop"></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
if anyof( allof( header :regex "x-spam-status" "BAYES_[6-9][0-9]",
not header :contains "x-spam-flag" "yes" ),
allof( header :regex "x-spam-status" "BAYES_[0-4][0-9]",
header :contains "x-spam-flag" "yes" ) )
{
fileinto "INBOX/trash";
stop;
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">body</str></control><crlf/><control name="require"><str type="quoted">fileinto</str></control><crlf/><control name="require"><str type="quoted">imap4flags</str></control><crlf/><crlf/><comment type="hash">SCRIPTNAME: Script part 0</comment><comment type="hash"># Flag: |UniqueId:2|Rulename: Mail delivery failed "bae.vo.pb+ma@gmail.com"</comment><control name="if"><test name="allof"><testlist><test name="header"><tag>contains</tag><str type="quoted">From</str><str type="quoted">mailer-daemon@foo.de</str><crlf/></test><test name="header"><tag>matches</tag><str type="quoted">Subject</str><str type="quoted">Mail delivery failed: returning message to sender</str><crlf/></test><test name="size"><tag>under</tag><num>10000</num><crlf/></test><test name="body"><tag>text</tag><tag>contains</tag><str type="quoted">&lt;blo@dd.com&gt;</str><crlf/></test></testlist></test><crlf/><block><crlf/><action name="fileinto"><str type="quoted">folder</str></action><crlf/><action name="addflag"><list><str type="quoted">\seen</str></list></action><crlf/><action name="stop"></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "body";
require "fileinto";
require "imap4flags";
#SCRIPTNAME: Script part 0
## Flag: |UniqueId:2|Rulename: Mail delivery failed "bae.vo.pb+ma@gmail.com"
if allof (header :contains "From" "mailer-daemon@foo.de"
, header :matches "Subject" "Mail delivery failed: returning message to sender"
, size :under 10000
, body :text :contains "<blo@dd.com>"
)
{
fileinto "folder";
addflag [ "\\seen" ];
stop;
}
<?xml version='1.0'?><script><control name="if"><test name="not"><test name="envelope"><tag>contains</tag><str type="quoted">from</str><str type="quoted">corpdomain.com</str></test></test><block><crlf/><control name="if"><test name="envelope"><tag>contains</tag><str type="quoted">to</str><str type="quoted">betty@corpdomain.com</str></test><block><crlf/><action name="reject"><str type="quoted">Betty is not allowed to receive Email from the outside. Please contact
sales@corpdomain.com</str></action><crlf/><action name="stop"></action><crlf/></block></control><crlf/></block></control><crlf/></script>
\ No newline at end of file
if not envelope :contains "from" "corpdomain.com" {
if envelope :contains "to" "betty@corpdomain.com" {
reject "Betty is not allowed to receive Email from the outside. Please contact
sales@corpdomain.com";
stop;
}
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">fileinto</str></control><crlf/><control name="require"><str type="quoted">copy</str></control><crlf/><control name="require"><str type="quoted">mailbox</str></control><crlf/><crlf/><comment type="hash">Script name: scriptname</comment><crlf/><control name="if"><test name="header"><tag>is</tag><str type="quoted">Content-Type</str><str type="quoted">png</str><crlf/></test><block><crlf/><action name="fileinto"><tag>copy</tag><tag>create</tag><str type="quoted">INBOX</str></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "fileinto";
require "copy";
require "mailbox";
#Script name: scriptname
if header :is "Content-Type" "png"
{
fileinto :copy :create "INBOX";
}
<?xml version='1.0'?><script><control name="foreverypart"><tag>name</tag><str type="quoted">dd</str><crlf/><block><crlf/><control name="if"><test name="allof"><testlist><crlf/><test name="header"><tag>mime</tag><tag>param</tag><str type="quoted">filename</str><tag>contains</tag><crlf/><str type="quoted">Content-Disposition</str><str type="quoted">important</str></test><crlf/><test name="header"><tag>mime</tag><tag>subtype</tag><str type="quoted">Content-Type</str><str type="quoted">pdf</str></test><crlf/><test name="size"><tag>over</tag><num quantifier="K">102400</num></test></testlist></test><crlf/><block><crlf/><action name="fileinto"><str type="quoted">INBOX.important</str></action><crlf/><control name="break"></control><crlf/></block></control><crlf/></block></control><crlf/></script>
\ No newline at end of file
foreverypart :name "dd"
{
if allof (
header :mime :param "filename" :contains
"Content-Disposition" "important",
header :mime :subtype "Content-Type" "pdf",
size :over 100K)
{
fileinto "INBOX.important";
break;
}
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">include</str></control><crlf/><control name="require"><str type="quoted">copy</str></control><crlf/><control name="require"><str type="quoted">imapflags</str></control><crlf/><control name="require"><str type="quoted">subaddress</str></control><crlf/><control name="require"><str type="quoted">reject</str></control><crlf/><crlf/><comment type="hash">SCRIPTNAME: test</comment><action name="include"><tag>personal</tag><tag>optional</tag><tag>once</tag><str type="quoted">sdqd</str></action><crlf/><action name="include"><tag>global</tag><tag>optional</tag><str type="quoted">qsdqd</str></action><crlf/><action name="global"><str type="quoted">globalvar</str></action><crlf/><action name="set"><str type="quoted">globalvar</str><str type="quoted">415</str></action><crlf/><action name="redirect"><tag>copy</tag><str type="quoted">folder</str></action><crlf/><crlf/><crlf/><comment type="hash">SCRIPTNAME: test2</comment><control name="if"><test name="false"><crlf/></test><block><crlf/><action name="removeflag"><list><str type="quoted">\Flagged</str><str type="quoted">\Seen</str><str type="quoted">\Draft</str></list></action><crlf/></block></control><control name="elsif"><test name="address"><tag>all</tag><tag>is</tag><str type="quoted">Reply-To</str><str type="quoted">foo@kde.org</str><crlf/></test><block><crlf/><action name="reject"><str type="multiline">rejected </str></action><crlf/><crlf/></block></control><control name="else"><block><crlf/><action name="keep"><tag>flags</tag><list><str type="quoted">\Answered</str></list></action><crlf/></block></control><crlf/><crlf/></script>
\ No newline at end of file
require "include";
require "copy";
require "imapflags";
require "subaddress";
require "reject";
#SCRIPTNAME: test
include :personal :optional :once "sdqd";
include :global :optional "qsdqd";
global "globalvar";
set "globalvar" "415";
redirect :copy "folder";
#SCRIPTNAME: test2
if false
{
removeflag [ "\\Flagged", "\\Seen", "\\Draft" ];
} elsif address :all :is "Reply-To" "foo@kde.org"
{
reject text:
rejected
.
;
} else {
keep :flags [ "\\Answered" ];
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">imapflags</str></control><crlf/><crlf/><comment type="hash">SCRIPTNAME: test1</comment><control name="if"><test name="hasflag"><tag>is</tag><str type="quoted">foo</str><crlf/></test><block><crlf/></block></control><crlf/><crlf/></script>
\ No newline at end of file
require "imapflags";
#SCRIPTNAME: test1
if hasflag :is "foo"
{
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">include</str></control><crlf/><control name="require"><str type="quoted">include</str></control><crlf/><control name="require"><str type="quoted">spamtest</str></control><crlf/><control name="require"><str type="quoted">relational</str></control><crlf/><control name="require"><str type="quoted">comparator-i;ascii-numeric</str></control><crlf/><control name="require"><str type="quoted">enclose</str></control><crlf/><comment type="hash">Script name: include</comment><crlf/><action name="include"><tag>personal</tag><str type="quoted">toto.siv</str></action><crlf/><action name="global"><str type="quoted">global-variable</str></action><crlf/><action name="set"><str type="quoted">test-variable</str><str type="quoted">25</str></action><crlf/><control name="if"><test name="virustest"><tag>value</tag><str type="quoted">gt</str><tag>comparator</tag><str type="quoted">i;ascii-numeric</str><str type="quoted">5</str><crlf/></test><block><crlf/><action name="enclose"><tag>subject</tag><str type="quoted">toto</str><tag>headers</tag><str type="quoted">subject</str><str type="multiline"> text to displaying</str></action><crlf/><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "include";
require "include";
require "spamtest";
require "relational";
require "comparator-i;ascii-numeric";
require "enclose";
#Script name: include
include :personal "toto.siv";
global "global-variable";
set "test-variable" "25";
if virustest :value "gt" :comparator "i;ascii-numeric" "5"
{
enclose :subject "toto" :headers "subject" text:
text to displaying
.
;
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">date</str></control><crlf/><control name="require"><str type="quoted">imapflags</str></control><crlf/><crlf/><comment type="hash">SCRIPTNAME: xxx</comment><control name="if"><test name="date"><tag>is</tag><str/><str type="quoted">year</str><str type="quoted">0000</str><crlf/></test><block><crlf/><action name="keep"><tag>flags</tag><list><str type="quoted">\Flagged</str><str type="quoted">\Seen</str></list></action><crlf/><action name="keep"></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "date";
require "imapflags";
#SCRIPTNAME: xxx
if date :is "" "year" "0000"
{
keep :flags [ "\\Flagged", "\\Seen" ];
keep;
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">mailbox</str></control><crlf/><control name="require"><str type="quoted">include</str></control><crlf/><crlf/><comment type="hash">Script name: maiboxexist</comment><crlf/><control name="if"><test name="mailboxexists"><str type="quoted">INBOX2</str><crlf/></test><block><crlf/><action name="return"></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "mailbox";
require "include";
#Script name: maiboxexist
if mailboxexists "INBOX2"
{
return;
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">envelope</str></control><crlf/><control name="require"><str type="quoted">subaddress</str></control><crlf/><control name="require"><str type="quoted">foreverypart</str></control><crlf/><crlf/><comment type="hash">Script name: not condition</comment><crlf/><control name="if"><test name="not"><test name="envelope"><tag>localpart</tag><tag>is</tag><str type="quoted">Reply-To</str><str type="quoted">montel@kde.org</str><crlf/></test></test><block><crlf/><control name="break"></control><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "envelope";
require "subaddress";
require "foreverypart";
#Script name: not condition
if not envelope :localpart :is "Reply-To" "montel@kde.org"
{
break ;
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">ihave</str></control><crlf/><control name="require"><str type="quoted">foreverypart</str></control><crlf/><crlf/><comment type="hash">Script name: not condition</comment><crlf/><control name="if"><test name="allof"><testlist><test name="not"><test name="header"><tag>is</tag><str type="quoted">Content-Type</str><str type="quoted">sdfsdf</str><crlf/></test></test><test name="ihave"><str type="quoted">xvwx</str><crlf/></test></testlist></test><crlf/><block><crlf/><control name="break"></control><crlf/></block></control><crlf/><crlf/></script>
\ No newline at end of file
require "ihave";
require "foreverypart";
#Script name: not condition
if allof (not header :is "Content-Type" "sdfsdf"
, ihave "xvwx"
)
{
break ;
}
<?xml version='1.0'?><script><action name="notify"><tag>importance</tag><str type="quoted">1</str><tag>message</tag><str type="quoted">You got mail</str><str type="quoted">xmpp:tim@example.com?message;subject=SIEVE</str></action><crlf/></script>
\ No newline at end of file
notify :importance "1" :message "You got mail" "xmpp:tim@example.com?message;subject=SIEVE";
<?xml version='1.0'?><script><control name="require"><str type="quoted">convert</str></control><crlf/><crlf/><comment type="hash">Script name: notify</comment><crlf/><control name="if"><test name="convert"><str type="quoted">image/jpeg</str><str type="quoted">image/jpeg</str><list><str type="quoted">pix-x=300</str><str type="quoted">pix-y=200</str></list><crlf/></test><block><crlf/><action name="notify"><tag>importance</tag><str type="quoted">2</str><tag>message</tag><str type="quoted">message !!!</str></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "convert";
#Script name: notify
if convert "image/jpeg" "image/jpeg" ["pix-x=300","pix-y=200"]
{
notify :importance "2" :message "message !!!";
}
<?xml version='1.0'?><script><comment type="hash"> " create a problem during parsing</comment><action name="addheader"><str type="quoted">X-Sieve-Filtered</str><str type="quoted">&lt;kim@job.example.com&gt;</str></action><crlf/></script>
\ No newline at end of file
# < create a problem during parsing
addheader "X-Sieve-Filtered" "<kim@job.example.com>";
<?xml version='1.0'?><script><control name="require"><str type="quoted">ihave</str></control><crlf/><control name="require"><str type="quoted">copy</str></control><crlf/><crlf/><comment type="hash">Script name: redirect</comment><crlf/><control name="if"><test name="ihave"><str type="quoted">redirect</str><crlf/></test><block><crlf/><action name="redirect"><tag>copy</tag><str type="quoted">montel@kde.org</str></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "ihave";
require "copy";
#Script name: redirect
if ihave "redirect"
{
redirect :copy "montel@kde.org";
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">regex</str></control><crlf/><crlf/><comment type="hash"> Try to catch unsolicited email.</comment><control name="if"><test name="anyof"><testlist><crlf/><comment type="hash"> if a message is not to me (with optional +detail),</comment><test name="not"><test name="address"><tag>regex</tag><list><str type="quoted">to</str><str type="quoted">cc</str><str type="quoted">bcc</str></list><crlf/><str type="quoted">me(\\+.*)?@company\\.com</str></test></test><crlf/><crlf/><comment type="hash"> or the subject is all uppercase (no lowercase)</comment><test name="header"><tag>regex</tag><tag>comparator</tag><str type="quoted">i;octet</str><str type="quoted">subject</str><crlf/><str type="quoted">^[^[:lower:]]+$</str></test></testlist></test><block><crlf/><crlf/><action name="discard"></action><comment type="hash"> junk it</comment></block></control><crlf/></script>
\ No newline at end of file
require "regex";
# Try to catch unsolicited email.
if anyof (
# if a message is not to me (with optional +detail),
not address :regex ["to", "cc", "bcc"]
"me(\\\\+.*)?@company\\\\.com",
# or the subject is all uppercase (no lowercase)
header :regex :comparator "i;octet" "subject"
"^[^[:lower:]]+$" ) {
discard; # junk it
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">ihave</str></control><crlf/><control name="require"><str type="quoted">reject</str></control><crlf/><crlf/><comment type="hash">Script name: reject</comment><crlf/><control name="if"><test name="ihave"><str type="quoted">reject</str><crlf/></test><block><crlf/><action name="reject"><str type="multiline"> sorry rejected
thanks</str></action><crlf/><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "ihave";
require "reject";
#Script name: reject
if ihave "reject"
{
reject text:
sorry rejected
thanks
.
;
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">ihave</str></control><crlf/><control name="require"><str type="quoted">imapflags</str></control><crlf/><crlf/><comment type="hash">Script name: remove flags</comment><crlf/><control name="if"><test name="ihave"><str type="quoted">reject</str><crlf/></test><block><crlf/><action name="removeflag"><list><str type="quoted">\Answered</str><str type="quoted">\Flagged</str><str type="quoted">\Seen</str></list></action><crlf/><action name="removeflag"><list><str type="quoted">\Draft</str></list></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "ihave";
require "imapflags";
#Script name: remove flags
if ihave "reject"
{
removeflag [ "\\Answered", "\\Flagged", "\\Seen" ];
removeflag [ "\\Draft" ];
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">replace</str></control><crlf/><crlf/><comment type="hash">Script name: replace</comment><crlf/><control name="if"><test name="true"></test><block><crlf/><action name="replace"><tag>subject</tag><str type="quoted">subject</str><tag>from</tag><str type="quoted">montel@kde.org</str><str type="multiline"> replace text</str></action><crlf/><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "replace";
#Script name: replace
if true {
replace :subject "subject" :from "montel@kde.org" text:
replace text
.
;
}
<?xml version='1.0'?><script><control name="if"><test name="header"><tag>is</tag><str type="quoted">Sender</str><str type="quoted">owner-ietf-mta-filters@example.org</str><crlf/></test><block><crlf/><action name="set"><str type="quoted">MyFlags</str><str type="quoted">\Flagged $Work</str></action><crlf/><comment type="hash"> Message will have both "\Flagged" and $Work flags</comment><action name="keep"><tag>flags</tag><str type="quoted">${MyFlags}</str></action><crlf/></block></control><crlf/><crlf/></script>
\ No newline at end of file
if header :is "Sender" "owner-ietf-mta-filters@example.org"
{
set "MyFlags" "\\Flagged $Work";
# Message will have both "\Flagged" and $Work flags
keep :flags "${MyFlags}";
}
<?xml version='1.0'?><script><control name="require"><str type="quoted">imapflags</str></control><crlf/><control name="if"><test name="address"><str type="quoted">From</str><str type="quoted">someone@example.org</str></test><block><crlf/><action name="setflag"><str type="quoted">\Seen</str></action><crlf/></block></control><crlf/></script>
\ No newline at end of file
require "imapflags";
if address "From" "someone@example.org" {
setflag "\\Seen";
}
<?xml version='1.0'?><script><crlf/><control name="if"><test name="address"><tag>matches</tag><tag>detail</tag><str type="quoted">to</str><str type="quoted">*</str></test><block><crlf/><action name="set"><str type="quoted">extension_name</str><str type="quoted">${1}</str></action><crlf/></block></control><crlf/></script>
\ No newline at end of file