Warning, /frameworks/syntax-highlighting/autotests/folding/test.sieve.fold is written in an unsupported language. File is not indexed.
0001 # Sieve syntax highlighting test 0002 # see RFC 5228 0003 0004 # comments §2.3. 0005 0006 # Single line with alerts TODO ### 0007 <beginfold id='1'>/*</beginfold id='1'> 0008 Multiline comment with alerts FIXME 0009 this also should be folding region 0010 <endfold id='1'>*/</endfold id='1'> 0011 0012 # literal data §2.4. 0013 # numbers §2.4.1. 0014 42 0015 100K 0016 10M 0017 3G 0018 0019 # strings §2.4.2. 0020 "string" 0021 "string\nwith\"special chars" 0022 # not a string 0023 "multi \ 0024 line \ 0025 #with\a \ 0026 continuation" 0027 # not a string 0028 <beginfold id='2'>text:</beginfold id='2'> 0029 Multiline 0030 string\" "with quotes" 0031 or # comments 0032 this should also be a folding region 0033 .dot 0034 ..dot 0035 dotstuffed dot: 0036 .. 0037 ending with a single . 0038 <endfold id='2'>.</endfold id='2'> 0039 0040 # encoded characters §2.4.2.4. 0041 # valid 0042 "$${hex:24 24}" 0043 "${unicode:40}" 0044 "$${hex:40}" 0045 "${hex: da }" 0046 "${hex:FE }" 0047 "${HEX: 40}" 0048 "${unicode:40}" 0049 "${UNICODE:40}" 0050 "${UnICoDE:0000040}" 0051 "${Unicode:ff}" 0052 #invalid 0053 "${hex:40" 0054 "${hex:4${hex:30}}" 0055 "${ unicode:40}" 0056 "${Unicode:Cool}" 0057 # semantic errors, syntactically correct 0058 "${hex:400}" 0059 "${unicode:200000}" 0060 "${Unicode:DF01}" 0061 0062 # test lists §2.5.1 0063 if anyof (not exists ["From", "Date"], 0064 header :contains "from" "fool@example.com") <beginfold id='3'>{</beginfold id='3'> 0065 discard; 0066 <endfold id='3'>}</endfold id='3'> 0067 if allof (not exists ["From", "Date"], 0068 header :contains "from" "fool@example.com") <beginfold id='3'>{</beginfold id='3'> 0069 discard; 0070 <endfold id='3'>}</endfold id='3'> 0071 0072 # match types §2.7.1. 0073 :contains 0074 :matches 0075 :is 0076 0077 # comparators §2.7.3. 0078 if header :contains :comparator "i;octet" "Subject" "MAKE MONEY FAST" <beginfold id='3'>{</beginfold id='3'> 0079 discard; 0080 <endfold id='3'>}</endfold id='3'> 0081 0082 # comparison against addresses §2.7.4. 0083 :localpart 0084 :domain 0085 :all 0086 0087 # commands §2.9. 0088 keep; 0089 fileinto "inbox.bla"; 0090 redirect "test@kde.org"; 0091 discard; 0092 0093 # control if §3.1. 0094 # this also should create folding regions 0095 if header :contains "from" "foo" <beginfold id='3'>{</beginfold id='3'> 0096 discard; 0097 <endfold id='3'>}</endfold id='3'> elsif header :contains ["subject"] ["$$$"] <beginfold id='3'>{</beginfold id='3'> 0098 discard; 0099 <endfold id='3'>}</endfold id='3'> else <beginfold id='3'>{</beginfold id='3'> 0100 fileinto "INBOX"; 0101 <endfold id='3'>}</endfold id='3'> 0102 0103 # control require §3.2. 0104 require "fileinto"; 0105 require ["vacation", "imapflags"]; 0106 0107 # control stop §3.3. 0108 stop; 0109 0110 # test commands §5. 0111 address 0112 allof 0113 anyof 0114 exists 0115 false 0116 header 0117 not 0118 size 0119 true 0120 0121 # test address §5.1. 0122 if address :is :all "from" "kde@example.com" <beginfold id='3'>{</beginfold id='3'> 0123 discard; 0124 <endfold id='3'>}</endfold id='3'> elsif address :domain :is ["From", "To"] "example.com" <beginfold id='3'>{</beginfold id='3'> # comment 0125 keep; # comment 0126 <endfold id='3'>}</endfold id='3'> 0127 0128 # test envelope §5.4. 0129 if envelope :all :is "from" "kde@example.com" <beginfold id='3'>{</beginfold id='3'> 0130 discard; 0131 <endfold id='3'>}</endfold id='3'> 0132 0133 # test exists §5.5. 0134 if not exists ["From","Date"] <beginfold id='3'>{</beginfold id='3'> 0135 discard; 0136 <endfold id='3'>}</endfold id='3'> 0137 0138 # test header §5.7. 0139 not header :matches "Cc" "?*" 0140 0141 # test size §5.9. 0142 if size :over 500K <beginfold id='3'>{</beginfold id='3'> discard; <endfold id='3'>}</endfold id='3'> 0143 if size :under 1M <beginfold id='3'>{</beginfold id='3'> keep; <endfold id='3'>}</endfold id='3'> else <beginfold id='3'>{</beginfold id='3'> discard; <endfold id='3'>}</endfold id='3'> 0144 0145 0146 <beginfold id='1'>/*</beginfold id='1'> 0147 * Extensions 0148 * see https://www.iana.org/assignments/sieve-extensions/sieve-extensions.xhtml 0149 <endfold id='1'>*/</endfold id='1'> 0150 0151 # Body RFC5173 0152 :raw 0153 :content 0154 :text 0155 if body :raw :contains "MAKE MONEY FAST" <beginfold id='3'>{</beginfold id='3'> 0156 discard; 0157 <endfold id='3'>}</endfold id='3'> 0158 if body :content "text" :contains ["bla", "blub"] <beginfold id='3'>{</beginfold id='3'> 0159 fileinto "inbox.foo"; 0160 <endfold id='3'>}</endfold id='3'> 0161 0162 # Convert RFC6558 0163 require ["convert"]; 0164 convert "image/tiff" "image/jpeg" ["pix-x=320","pix-y=240"]; 0165 0166 # Copy RFC3894 0167 require ["copy", "fileinto"]; 0168 fileinto :copy "incoming"; 0169 0170 # Date RFC5260 0171 require ["date", "relational", "fileinto"]; 0172 if allof(header :is "from" "boss@example.com", 0173 date :value "ge" :originalzone "date" "hour" "09", 0174 date :value "lt" :originalzone "date" "hour" "17") 0175 <beginfold id='3'>{</beginfold id='3'> fileinto "urgent"; <endfold id='3'>}</endfold id='3'> 0176 if anyof(date :is "received" "weekday" "0", 0177 date :is "received" "weekday" "6") 0178 <beginfold id='3'>{</beginfold id='3'> fileinto "weekend"; <endfold id='3'>}</endfold id='3'> 0179 if anyof(currentdate :is "weekday" "0", 0180 currentdate :is "weekday" "6", 0181 currentdate :value "lt" "hour" "09", 0182 currentdate :value "ge" "hour" "17") 0183 <beginfold id='3'>{</beginfold id='3'> redirect "pager@example.com"; <endfold id='3'>}</endfold id='3'> 0184 if allof(currentdate :value "ge" "date" "2007-06-30", 0185 currentdate :value "le" "date" "2007-07-07") 0186 <beginfold id='3'>{</beginfold id='3'> vacation :days 7 "I'm away during the first week in July."; <endfold id='3'>}</endfold id='3'> 0187 0188 require ["date", "variables", "fileinto"]; 0189 if currentdate :matches "month" "*" <beginfold id='3'>{</beginfold id='3'> set "month" "${1}"; <endfold id='3'>}</endfold id='3'> 0190 if currentdate :matches "year" "*" <beginfold id='3'>{</beginfold id='3'> set "year" "${1}"; <endfold id='3'>}</endfold id='3'> 0191 fileinto "${month}-${year}"; 0192 0193 require ["variables", "date", "editheader"]; 0194 if currentdate :matches "std11" "*" <beginfold id='3'>{</beginfold id='3'>addheader "Processing-date" "${0}";<endfold id='3'>}</endfold id='3'> 0195 0196 require ["date", "relational", "index"]; 0197 if date :value "gt" :index 2 :zone "-0500" "received" "iso8601" "2007-02-26T09:00:00-05:00" 0198 <beginfold id='3'>{</beginfold id='3'> redirect "aftercutoff@example.org"; <endfold id='3'>}</endfold id='3'> 0199 0200 if header :index 1 :matches "received" "*(* [*.*.*.*])*" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0201 0202 # Duplicate RFC7352 0203 require ["duplicate", "variables"]; 0204 if duplicate <beginfold id='3'>{</beginfold id='3'> discard; <endfold id='3'>}</endfold id='3'> 0205 if duplicate :header "message-id" <beginfold id='3'>{</beginfold id='3'> discard; <endfold id='3'>}</endfold id='3'> 0206 if header :matches "message-id" "*" <beginfold id='3'>{</beginfold id='3'> 0207 if duplicate :uniqueid "${0}" <beginfold id='3'>{</beginfold id='3'> discard; <endfold id='3'>}</endfold id='3'> 0208 <endfold id='3'>}</endfold id='3'> 0209 0210 # Editheader RFC5293 0211 addheader "X-Hello" "World"; 0212 deleteheader :index 1 "X-Hello"; 0213 0214 # Enclose RFC5703 0215 :mime 0216 :anychild 0217 :type 0218 :subtype 0219 :contenttype 0220 :param 0221 replace 0222 enclose 0223 extracttext 0224 if header :mime :type "Content-Type" "image" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0225 replace "Executable attachment removed by user filter"; 0226 foreverypart <beginfold id='3'>{</beginfold id='3'> 0227 if header :mime :param "filename" :matches ["Content-Type", "Content-Disposition"] 0228 ["*.com", "*.exe", "*.vbs", "*.scr", "*.pif", "*.hta", "*.bat", "*.zip" ] <beginfold id='3'>{</beginfold id='3'> 0229 # these attachment types are executable 0230 enclose :subject "Warning" <beginfold id='2'>text:</beginfold id='2'> 0231 WARNING! The enclosed message contains executable attachments. 0232 These attachment types may contain a computer virus program 0233 that can infect your computer and potentially damage your data. 0234 <endfold id='2'>.</endfold id='2'> 0235 ; 0236 break; 0237 <endfold id='3'>}</endfold id='3'> 0238 <endfold id='3'>}</endfold id='3'> 0239 extracttext :first 100 "msgcontent"; 0240 0241 # Notify RFC5435 0242 notify :importance "1" :message "This is probably very important" "mailto:kde@example.com"; 0243 notify :message "${from_addr}${env_from}: ${subject}" "mailto:kde@example.com"; 0244 if not valid_notify_method ["mailto:", "http://gw.example.net/notify?test"] <beginfold id='3'>{</beginfold id='3'> stop; <endfold id='3'>}</endfold id='3'> 0245 if notify_method_capability "xmpp:tim@example.com?message;subject=SIEVE" "Online" "yes" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0246 set :encodeurl "body_param" "stuff"; 0247 0248 # Envelope DSN RFC6009 0249 if envelope "notify" "SUCCESS" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0250 if allof (envelope "notify" "FAILURE", envelope :comparator "i;ascii-numeric" :count "eq" "notify" "1") <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0251 if envelope :matches "orcpt" "rfc822;*@example.com" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0252 if anyof (envelope :contains "bytimerelative" "-", envelope :value "eq" :comparator "i;ascii-numeric" "bytimerelative" "0") <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0253 redirect :copy :notify "NEVER" "elsewhere@example.com"; 0254 redirect :copy :bytimerelative 600 "cellphone@example.com"; 0255 redirect :copy :bytimeabsolute "${date}T20:00:00${zone}" :bymode "return" "cellphone@example.com"; 0256 0257 # Environment RFC5183 0258 if environment :contains "item" "" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0259 0260 # Reject RFC5429 0261 ereject "I no longer accept mail from this address"; 0262 reject <beginfold id='2'>text:</beginfold id='2'> 0263 Your message is too big. If you want to send me a big attachment, 0264 put it on a public web site and send me a URL. 0265 <endfold id='2'>.</endfold id='2'> 0266 ; 0267 0268 # External Lists RFC6134 0269 if envelope :list "from" ":addrbook:default" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0270 if currentdate :list "date" "tag:example.com,2011-01-01:localHolidays" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0271 if allof (envelope :detail "to" "mylist", header :list "from" "tag:example.com,2010-05-28:mylist") <beginfold id='3'>{</beginfold id='3'> 0272 redirect :list "tag:example.com,2010-05-28:mylist"; 0273 <endfold id='3'>}</endfold id='3'> 0274 if string :list "${ip}" "tag:example.com,2011-04-10:DisallowedIPs" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0275 if header :mime :param "filename" :list ["Content-Type", "Content-Disposition"] "tag:example.com,2011-04-10:BadFileNameExts" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0276 0277 # ihave RFC5463 0278 if ihave "fileinto" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0279 error "failed!"; 0280 0281 # IMAP Sieve RFC6785 0282 if anyof (environment :is "imap.cause" "APPEND", environment :is "imap.cause" "COPY") <beginfold id='3'>{</beginfold id='3'> 0283 if environment :is "imap.mailbox" "ActionItems" <beginfold id='3'>{</beginfold id='3'> 0284 redirect :copy "actionitems@example.com"; 0285 <endfold id='3'>}</endfold id='3'> 0286 <endfold id='3'>}</endfold id='3'> 0287 0288 # IMAP4 Flags RFC5232 0289 setflag "\\Deleted"; 0290 setflag "flagvar" "\\Flagged"; 0291 addflag "flagvar" "\\Deleted"; 0292 addflag "flagvar" ["\\Deleted", "\\Answered"]; 0293 removeflag "flagvar" "$MDNRequired"; 0294 hasflag :contains "MyVar" "Junk" 0295 hasflag :contains "${MyVar}" ["label", "forward"] 0296 hasflag :count "ge" :comparator "i;ascii-numeric" "MyFlags" 2 0297 fileinto :flags "\\Deleted" "INBOX.bla"; 0298 0299 # Include RFC6609 0300 include :personal "always_allow"; 0301 include :global "spam_tests"; 0302 return; 0303 global "i_am_on_vacation"; 0304 set "global.i_am_on_vacation" "1"; 0305 0306 # Mailbox RFC5490 0307 if mailboxexists "bla" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0308 fileinto :create "inbox.bla"; 0309 if metadata :is "INBOX" "/private/vendor/vendor.isode/auto-replies" "on" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0310 if metadataexists "INBOX" "/private/vendor/foo" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0311 if servermetadata :matches "/private/vendor/vendor.isode/notification-uri" "*" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0312 if servermetadataexists "/private/vendor/foo" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0313 0314 # Regexp (draft) 0315 if not address :regex ["to", "cc", "bcc"] "me(\\+.*)?@company\\.com" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0316 0317 # Relational RFC5231 0318 if address :count "ge" :comparator "i;ascii-numeric" ["to", "cc"] ["3"] <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0319 if header :value "lt" :comparator "i;ascii-numeric" ["x-priority"] ["3"] <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0320 0321 # Spamtest RFC5235 0322 if spamtest :value "eq" :comparator "i;ascii-numeric" "0" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0323 elsif spamtest :value "ge" :comparator "i;ascii-numeric" "3" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0324 elsif spamtest :percent :value "lt" :comparator "i;ascii-numeric" "37" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0325 if virustest :value "eq" :comparator "i;ascii-numeric" "4" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0326 0327 # Subaddress RFC5233 0328 if envelope :user "to" "postmaster" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0329 if envelope :detail "to" "mta-filters" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0330 0331 # Vacation RFC5230 0332 vacation "I'm out"; 0333 vacation :subject "Automatic response to: ${1}" 0334 "I'm away -- send mail to foo in my absence"; 0335 vacation :handle "ran-away" "I'm out"; 0336 vacation :mime <beginfold id='2'>text:</beginfold id='2'> 0337 Content-Type: multipart/alternative; boundary=foo 0338 0339 --foo 0340 0341 Hello ${sender}, I'm at the beach relaxing. 0342 0343 --foo 0344 Content-Type: text/html; charset=us-ascii 0345 0346 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" 0347 "http://www.w3.org/TR/REC-html40/strict.dtd"> 0348 <HTML><HEAD><TITLE>How to relax</TITLE> 0349 <BASE HREF="http://home.example.com/pictures/"></HEAD> 0350 <BODY><P>I'm at the <A HREF="beach.gif">beach</A> relaxing. 0351 </BODY></HTML> 0352 0353 --foo-- 0354 <endfold id='2'>.</endfold id='2'> 0355 ; 0356 vacation :days 23 :addresses ["kde@example.edu"] "I'm away until October 19."; 0357 0358 # Vacation Seconds RFC6131 0359 vacation :addresses ["kde@example.edu"] :seconds 1800 0360 "I am in a meeting, and do not have access to email."; 0361 0362 # Variables RFC5229 0363 "&%${}!" # invalid 0364 "${doh!}" #invalid 0365 "${company}" 0366 "bla ${var42} blub" 0367 "${1}" 0368 "${BAD${Company}" # second one is the variable 0369 "${President, ${Company} Inc.}" # inner one is the variable 0370 set "var" "value"; 0371 set "var2" "${var}"; 0372 0373 set "a" "juMBlEd lETteRS"; 0374 set :length "b" "${a}"; 0375 set :lower "b" "${a}"; 0376 set :upperfirst "b" "${a}"; 0377 set :upperfirst :lower "b" "${a}"; 0378 set :quotewildcard "b" "Rock*"; 0379 set :lowerfirst "b" "${a}"; 0380 0381 if string :matches " ${state} " "* pending *" <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'> 0382 0383 # Dovecot debug extension 0384 require "vnd.dovecot.debug"; 0385 if header :contains "subject" "hello" <beginfold id='3'>{</beginfold id='3'> 0386 debug_log "Subject header contains hello!"; 0387 <endfold id='3'>}</endfold id='3'>