[dev] ingo/lib/Script/sieve.php (take 2)

Marc Jauvin marc at register4less.com
Wed Jun 18 09:10:15 PDT 2003


Here are a few additions to the sieve Script:

- implements WhiteLists
- allow for "," as a seperator to build an array of header fields for rules
- allow for "," as a seperator to build an array of strings for rules

Please, verify an commit (or give feed-back :)

--
Marc Jauvin
450-441-5458
http://register4less.com

--
Horde developers mailing list
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: dev-unsubscribe at lists.horde.org
-------------- next part --------------
Index: config/tests.php.dist
===================================================================
RCS file: /repository/ingo/config/tests.php.dist,v
retrieving revision 1.2
diff -u -r1.2 tests.php.dist
--- config/tests.php.dist	29 Mar 2003 14:29:41 -0000	1.2
+++ config/tests.php.dist	18 Jun 2003 15:57:41 -0000
@@ -52,6 +52,9 @@
     'not exist');
 
 $fields = array();
+$fields['From,To,Cc,Bcc'] = array(
+    'label' => _("From,To,Cc,Bcc"),
+    'tests' => $headertests);
 $fields['To'] = array(
     'label' => _("To"),
     'tests' => $headertests);
@@ -81,6 +84,9 @@
     'tests' => $headertests);
 $fields['Received'] = array(
     'label' => _("Received"),
+    'tests' => $headertests);
+$fields['X-Fetchmail-Warning'] = array(
+    'label' => _("X-Fetchmail-Warning"),
     'tests' => $headertests);
 $fields['X-Spam-Level'] = array(
     'label' => _("X-Spam-Level"),
Index: lib/Script/sieve.php
===================================================================
RCS file: /repository/ingo/lib/Script/sieve.php,v
retrieving revision 1.23
diff -u -r1.23 sieve.php
--- lib/Script/sieve.php	17 Jun 2003 18:28:14 -0000	1.23
+++ lib/Script/sieve.php	18 Jun 2003 15:57:42 -0000
@@ -188,7 +188,13 @@
             $whitelist = $ingo_storage->retrieve('whitelist');
             $whitelistBlocks = array();;
             if (!empty($whitelist)) {
-                // Sieve whitelist TBP
+                $whitelistBlocks[] = &new Sieve_Comment(_("Whitelisted Addresses"));
+                $action = array();
+                $action[] = &new Sieve_Action_Keep();
+                $test = &new Sieve_Test_Address(array('headers' => "From\nSender\nResent-From", 'addresses' => implode("\n", $whitelist)));
+                $if = &new Sieve_If($test);
+                $if->setActions($action);
+                $whitelistBlocks[] = $if;
             }
         }
 
@@ -1143,12 +1149,12 @@
 
     function check()
     {
-        $headers = preg_split('(\r\n|\n|\r)', $this->_vars['headers']);
+        $headers = preg_split('(\r\n|\n|\r|,)', $this->_vars['headers']);
         if (count($headers) < 1) {
             return false;
         }
 
-        $strings = preg_split('(\r\n|\n|\r)', $this->_vars['strings']);
+        $strings = preg_split('(\r\n|\n|\r|,)', $this->_vars['strings']);
         if (count($strings) < 1) {
             return false;
         }
@@ -1165,7 +1171,7 @@
 
         $code .= $this->_vars['match-type'] . ' ';
 
-        $headers = preg_split('(\r\n|\n|\r)', $this->_vars['headers']);
+        $headers = preg_split('(\r\n|\n|\r|,)', $this->_vars['headers']);
         if (count($headers) > 1) {
             $code .= "[";
             $headerstr = '';
@@ -1180,7 +1186,7 @@
             return _("No Headers Specified");
         }
 
-        $strings = preg_split('(\r\n|\n|\r)', $this->_vars['strings']);
+        $strings = preg_split('(\r\n|\n|\r|,)', $this->_vars['strings']);
         if (count($strings) > 1) {
             $code .= "[";
             $stringlist = '';


More information about the dev mailing list