MFB: Add Sieve configuration to use UTF-8 encoded folder names (for Dovecot).
authorJan Schneider <jan@horde.org>
Fri, 18 Dec 2009 10:48:52 +0000 (11:48 +0100)
committerJan Schneider <jan@horde.org>
Fri, 18 Dec 2009 10:49:04 +0000 (11:49 +0100)
ingo/config/backends.php.dist
ingo/docs/CHANGES
ingo/lib/Script/Sieve.php

index 8e5dc0b..1f4b745 100644 (file)
@@ -209,7 +209,11 @@ $backends['sieve'] = array(
         // 'password' => '*****',
     ),
     'script' => 'sieve',
-    'scriptparams' => array(),
+    'scriptparams' => array(
+        // If using Dovecot or any other Sieve implementation that requires
+        // folder names to be UTF-8 encoded, set this parameter to true.
+        'utf8' => false,
+     ),
     'shares' => false
 );
 
index da6894d..4894051 100644 (file)
@@ -10,7 +10,7 @@ v2.0-git
 v1.2.4-cvs
 ----------
 
-
+[jan] Add Sieve configuration to use UTF-8 encoded folder names (for Dovecot).
 
 
 ------
index 3be309a..faec9cf 100644 (file)
@@ -266,7 +266,7 @@ class Ingo_Script_Sieve extends Ingo_Script {
             $action[] = new Sieve_Action_Keep();
             $action[] = new Sieve_Action_Removeflag(array('flags' => Ingo_Storage::FLAG_DELETED));
         } else {
-            $action[] = new Sieve_Action_Fileinto(array('folder' => $folder));
+            $action[] = new Sieve_Action_Fileinto(array_merge($this->_params, array('folder' => $folder)));
         }
 
         $action[] = new Sieve_Action_Stop();
@@ -435,9 +435,7 @@ class Ingo_Script_Sieve extends Ingo_Script {
         $this->_blocks[] = new Sieve_Comment(_("Spam Filter"));
 
         $actions = array();
-        $actions[] = new Sieve_Action_Fileinto(array(
-            'folder' => $spam->getSpamFolder()
-        ));
+        $actions[] = new Sieve_Action_Fileinto(array_merge($this->_params, array('folder' => $spam->getSpamFolder())));
 
         if ($GLOBALS['conf']['spam']['compare'] == 'numeric') {
             $vals = array(
@@ -506,7 +504,7 @@ class Ingo_Script_Sieve extends Ingo_Script {
                     $action[] = new Sieve_Action_Addflag(array('flags' => $filter['flags']));
                 }
 
-                $action[] = new Sieve_Action_Fileinto(array('folder' => $filter['action-value']));
+                $action[] = new Sieve_Action_Fileinto(array_merge($this->_params, array('folder' => $filter['action-value'])));
 
                 if (!empty($filter['flags'])) {
                     $action[] = new Sieve_Action_RemoveFlag(array('flags' => $filter['flags']));
@@ -540,7 +538,7 @@ class Ingo_Script_Sieve extends Ingo_Script {
                 }
 
                 $action[] = new Sieve_Action_Keep();
-                $action[] = new Sieve_Action_Fileinto(array('folder' => $filter['action-value']));
+                $action[] = new Sieve_Action_Fileinto(array_merge($this->_params, array('folder' => $filter['action-value'])));
 
                 if (!empty($filter['flags'])) {
                     $action[] = new Sieve_Action_RemoveFlag(array('flags' => $filter['flags']));
@@ -2515,6 +2513,9 @@ class Sieve_Action_Fileinto extends Sieve_Action {
     function Sieve_Action_Fileinto($vars = array())
     {
         $this->_vars['folder'] = (isset($vars['folder'])) ? $vars['folder'] : '';
+        if (!empty($vars['utf8'])) {
+            $this->_vars['folder'] = String::convertCharset($this->_vars['folder'], 'UTF7-IMAP', 'UTF-8');
+        }
     }
 
     /**