[dev] Patch: ingo/lib/Script/sieve.php (take 3)

Marc Jauvin marc at register4less.com
Wed Jun 18 12:42:12 PDT 2003


This fixes some logic problems for Blacklist rules insertion.

This version REPLACES the previous version I sent.

--
Marc Jauvin
450-441-5458
http://register4less.com
-------------- next part --------------
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 19:37:31 -0000
@@ -155,14 +155,14 @@
                         $test = &new Sieve_Test_Address(array('headers' => "From\nSender\nResent-From", 'addresses' => implode("\n", $temp)));
                         $if = &new Sieve_If($test);
                         $if->setActions($action);
-                        $this->addBlock($if);
+                        $blacklistBlocks[] = $if;
                         $temp = array();
                     }
                     if (count($wildcards) == 5) {
                         $test = &new Sieve_Test_Address(array('headers' => "From\nSender\nResent-From", 'match-type' => ':matches', 'addresses' => implode("\n", $wildcards)));
                         $if = &new Sieve_If($test);
                         $if->setActions($action);
-                        $this->addBlock($if);
+                        $blacklistBlocks[] = $if;
                         $wildcards = array();
                     }
                 }
@@ -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