Hello list, 

Sorry for posting this post here, not to trac, but I didn't find register page 
in trac-system.

I have noticed, that "fileinto" action in managesieve plugin save it's argument 
in utf7-imap encoding, but RFC requires utf8. This envolves  some problem, you 
may see discussion here http://dovecot.org/list/dovecot/2009-July/041690.html

Here is patch, which fixes this for version 0.3-rc1. I'm not php-programmer, so 
this might be done in more intelligent way, but this should be fixed:

--- lib/rcube_sieve.php.orig    2009-09-04 09:39:59.000000000 +0300
+++ lib/rcube_sieve.php 2009-09-04 09:38:32.000000000 +0300
@@ -326,7 +326,7 @@
            {
              case 'fileinto':
                $extension = 'fileinto';
-               $script .= "\tfileinto \"" . 
$this->_escape_string($action['target']) . "\";\n";
+               $script .= "\tfileinto \"" . 
$this->_utf7imap_to_utf8($this->_escape_string($action['target'])) . "\";\n";
              break;
              case 'redirect':
                $script .= "\tredirect \"" . 
$this->_escape_string($action['target']) . "\";\n";
@@ -499,7 +499,7 @@
            }
           elseif(preg_match('/^fileinto/', $content))
            {
-             $result[] = array('type' => 'fileinto', 'target' => 
$this->_parse_string($m[sizeof($m)-1])); 
+             $result[] = array('type' => 'fileinto', 'target' => 
$this->_utf8_to_utf7imap($this->_parse_string($m[sizeof($m)-1]))); 
            }
           elseif(preg_match('/^redirect/', $content))
            {
@@ -722,6 +722,29 @@
     
       return '["' . implode('","', $list) . '"]';
     }
+
+   /**
+    * Convert string value from utf8 to utf7-imap encoding 
+    *
+    * @param   string  Text 
+    */
+
+  private function _utf8_to_utf7imap($content)
+  {
+         return mb_convert_encoding("$content","UTF7-IMAP","UTF8");
+  }
+
+   /**
+    * Convert string value from utf7-imap to utf8 encoding 
+    *
+    * @param   string  Text 
+    */
+
+  private function _utf7imap_to_utf8($content)
+  {
+         return mb_convert_encoding("$content","UTF8","UTF7-IMAP");
+  }
+
 }
 
 ?>
_______________________________________________
List info: http://lists.roundcube.net/dev/

Reply via email to