diff options
| author | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-04-14 08:16:49 +0000 |
|---|---|---|
| committer | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-04-14 08:16:49 +0000 |
| commit | d5ae0be6dbe87b128dd7620bd955450414b9f3f1 (patch) | |
| tree | 17c2870e9a1dd83ce26f52cc0ae75582262da4ab /roundcubemail/program | |
| parent | 1e05ff714d94d483e99108a3b4ce188a90127a84 (diff) | |
Fix vcard folding with uncode characters (#1487868)
git-svn-id: https://svn.roundcube.net/trunk@4654 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program')
| -rw-r--r-- | roundcubemail/program/include/rcube_vcard.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/roundcubemail/program/include/rcube_vcard.php b/roundcubemail/program/include/rcube_vcard.php index 81d4d11ab..25041ea6a 100644 --- a/roundcubemail/program/include/rcube_vcard.php +++ b/roundcubemail/program/include/rcube_vcard.php @@ -465,7 +465,26 @@ class rcube_vcard 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) |
