From 024f6b3fdbc05055bc158f1da043b54973f0677a Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Fri, 18 Dec 2009 11:48:52 +0100 Subject: [PATCH] MFB: Add Sieve configuration to use UTF-8 encoded folder names (for Dovecot). --- ingo/config/backends.php.dist | 6 +++++- ingo/docs/CHANGES | 2 +- ingo/lib/Script/Sieve.php | 13 +++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ingo/config/backends.php.dist b/ingo/config/backends.php.dist index 8e5dc0bcc..1f4b7457a 100644 --- a/ingo/config/backends.php.dist +++ b/ingo/config/backends.php.dist @@ -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 ); diff --git a/ingo/docs/CHANGES b/ingo/docs/CHANGES index da6894dc6..48940517b 100644 --- a/ingo/docs/CHANGES +++ b/ingo/docs/CHANGES @@ -10,7 +10,7 @@ v2.0-git v1.2.4-cvs ---------- - +[jan] Add Sieve configuration to use UTF-8 encoded folder names (for Dovecot). ------ diff --git a/ingo/lib/Script/Sieve.php b/ingo/lib/Script/Sieve.php index 3be309a9e..faec9cfbd 100644 --- a/ingo/lib/Script/Sieve.php +++ b/ingo/lib/Script/Sieve.php @@ -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'); + } } /** -- 2.11.0