[Svn] r4654 - in trunk/roundcubemail: . program/include

trac at roundcube.net trac at roundcube.net
Thu Apr 14 10:16:50 CEST 2011


Author: thomasb
Date: 2011-04-14 03:16:49 -0500 (Thu, 14 Apr 2011)
New Revision: 4654

Modified:
   trunk/roundcubemail/CHANGELOG
   trunk/roundcubemail/program/include/rcube_vcard.php
Log:
Fix vcard folding with uncode characters (#1487868)

Modified: trunk/roundcubemail/CHANGELOG
===================================================================
--- trunk/roundcubemail/CHANGELOG	2011-04-13 12:37:54 UTC (rev 4653)
+++ trunk/roundcubemail/CHANGELOG	2011-04-14 08:16:49 UTC (rev 4654)
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Fix vcard folding with uncode characters (#1487868)
 - Keep all submitted data if contact form validation fails (#1487865)
 - Handle uncode strings in rcube_addressbook::normalize_string() (#1487866)
 - Fix bug where template name without plugin prefix was used in render_page hook

Modified: trunk/roundcubemail/program/include/rcube_vcard.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_vcard.php	2011-04-13 12:37:54 UTC (rev 4653)
+++ trunk/roundcubemail/program/include/rcube_vcard.php	2011-04-14 08:16:49 UTC (rev 4654)
@@ -465,7 +465,26 @@
 
   private static function rfc2425_fold_callback($matches)
   {
-    return ":\n  ".rtrim(chunk_split($matches[1], 72, "\n  "));
+    // use mb string function if available
+    if (function_exists('mb_ereg_replace')) {
+      mb_internal_encoding(RCMAIL_CHARSET);
+      return ":\n  " . mb_ereg_replace('(.{70})', "\\1\n  ", $matches[1]);
+    }
+    
+    // chunk_split string and avoid lines breaking multibyte characters
+    $c = 66;
+    $out = ":\n  " . substr($matches[1], 0, $c);
+    for ($n = $c; $c < strlen($matches[1]); $c++) {
+      // break if length > 70 or mutlibyte character starts after position 66
+      if ($n > 70 || ($n > 66 && ord($matches[1][$c]) >> 6 == 3)) {
+        $out .= "\n  ";
+        $n = 0;
+      }
+      $out .= $matches[1][$c];
+      $n++;
+    }
+
+    return $out;
   }
 
   private static function rfc2425_fold($val)

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list