* Mail: fix sieve rules for moving mails into folder containing non-ascii chars (Dovecot requires sieve rules in utf8, while Cyrus needs utf7-imap)

This commit is contained in:
Ralf Becker 2015-06-22 18:49:44 +00:00
parent e3748b2e95
commit 77e592da0f
4 changed files with 32 additions and 7 deletions

View File

@ -205,4 +205,22 @@ class emailadmin_imap_cyrus extends emailadmin_imap
} }
$this->disconnect(); $this->disconnect();
} }
/**
* Proxy former bosieve methods to internal emailadmin_sieve instance
*
* @param string $name
* @param array $params
* @throws Exception
*/
public function __call($name,array $params=null)
{
switch($name)
{
case 'setRules': // call setRules with 3. param of true, to enable utf7imap fileinto for Cyrus
$params += array(null, null, true);
break;
}
return parent::__call($name, $params);
}
} }

View File

@ -234,8 +234,13 @@ class emailadmin_script {
} }
// update and save sieve script /**
function updateScript ($connection) * update and save sieve script
*
* @param emailadmin_imap $connection
* @param boolean $utf7imap_fileinto =false true: encode foldernames with utf7imap, default utf8
*/
function updateScript ($connection, $utf7imap_fileinto=false)
{ {
#global $_SESSION,$default,$sieve; #global $_SESSION,$default,$sieve;
global $default,$sieve; global $default,$sieve;
@ -383,7 +388,8 @@ class emailadmin_script {
if (!$rule['unconditional']) $newruletext .= ") {\n\t"; if (!$rule['unconditional']) $newruletext .= ") {\n\t";
if (preg_match("/folder/i",$rule['action'])) { if (preg_match("/folder/i",$rule['action'])) {
$newruletext .= "fileinto \"" . $rule['action_arg'] . "\";"; $newruletext .= "fileinto \"" . ($utf7imap_fileinto ?
translation::convert($rule['action_arg'],'utf-8', 'utf7-imap') : $rule['action_arg']) . "\";";
} }
if (preg_match("/reject/i",$rule['action'])) { if (preg_match("/reject/i",$rule['action'])) {
$newruletext .= "reject text: \n" . $rule['action_arg'] . "\n.\n;"; $newruletext .= "reject text: \n" . $rule['action_arg'] . "\n.\n;";

View File

@ -569,13 +569,14 @@ class emailadmin_sieve extends Net_Sieve
* *
* @param array $_rules * @param array $_rules
* @param string $_scriptName * @param string $_scriptName
* @param boolean $utf7imap_fileinto =false true: encode foldernames with utf7imap, default utf8
*/ */
function setRules(array $_rules, $_scriptName=null) function setRules(array $_rules, $_scriptName=null, $utf7imap_fileinto=false)
{ {
$script = $this->retrieveRules($_scriptName); $script = $this->retrieveRules($_scriptName);
$script->debug = $this->debug; $script->debug = $this->debug;
$script->rules = $_rules; $script->rules = $_rules;
$ret = $script->updateScript($this); $ret = $script->updateScript($this, $utf7imap_fileinto);
$this->error = $script->errstr; $this->error = $script->errstr;
return $ret; return $ret;
} }

View File

@ -236,7 +236,7 @@ class mail_sieve
switch ($rules['action']) switch ($rules['action'])
{ {
case 'folder': case 'folder':
$content['action_folder_text'][] = translation::convert($rules['action_arg'],'utf-8','utf7-imap'); $content['action_folder_text'][] = $rules['action_arg'];
break; break;
case 'address': case 'address':
@ -285,7 +285,7 @@ class mail_sieve
switch ($content['action']) switch ($content['action'])
{ {
case 'folder': case 'folder':
$newRule['action_arg'] = translation::convert(implode($content['action_folder_text']), 'utf7-imap', 'utf-8'); $newRule['action_arg'] = implode($content['action_folder_text']);
break; break;
case 'address': case 'address':
$newRule['action_arg'] = implode(',',$content['action_address_text']); $newRule['action_arg'] = implode(',',$content['action_address_text']);