summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
Diffstat (limited to 'program')
-rw-r--r--program/include/rcube_contacts.php2
-rw-r--r--program/include/rcube_vcard.php24
-rw-r--r--program/steps/addressbook/export.inc4
3 files changed, 13 insertions, 17 deletions
diff --git a/program/include/rcube_contacts.php b/program/include/rcube_contacts.php
index 705551b03..3c713fe19 100644
--- a/program/include/rcube_contacts.php
+++ b/program/include/rcube_contacts.php
@@ -551,7 +551,7 @@ class rcube_contacts extends rcube_addressbook
$words .= ' ' . self::normalize_string($value);
}
}
- $out['vcard'] = $vcard->export();
+ $out['vcard'] = $vcard->export(false);
foreach ($this->table_cols as $col) {
$key = $col;
diff --git a/program/include/rcube_vcard.php b/program/include/rcube_vcard.php
index 086313cc1..fbe0783f1 100644
--- a/program/include/rcube_vcard.php
+++ b/program/include/rcube_vcard.php
@@ -206,9 +206,10 @@ class rcube_vcard
/**
* Convert the data structure into a vcard 3.0 string
*/
- public function export()
+ public function export($folded = true)
{
- return self::rfc2425_fold(self::vcard_encode($this->raw));
+ $vcard = self::vcard_encode($this->raw);
+ return $folded ? self::rfc2425_fold($vcard) : $vcard;
}
@@ -465,18 +466,13 @@ class rcube_vcard
private static function rfc2425_fold_callback($matches)
{
- // use mb string function if available
- if (function_exists('mb_ereg_replace')) {
- 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);
+ $c = 71;
+ $out .= 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 ";
+ // break if length > 75 or mutlibyte character starts after position 71
+ if ($n > 75 || ($n > 71 && ord($matches[1][$c]) >> 6 == 3)) {
+ $out .= "\n ";
$n = 0;
}
$out .= $matches[1][$c];
@@ -486,9 +482,9 @@ class rcube_vcard
return $out;
}
- private static function rfc2425_fold($val)
+ public static function rfc2425_fold($val)
{
- return preg_replace_callback('/:([^\n]{72,})/', array('self', 'rfc2425_fold_callback'), $val) . "\n";
+ return preg_replace_callback('/([^\n]{72,})/', array('self', 'rfc2425_fold_callback'), $val);
}
diff --git a/program/steps/addressbook/export.inc b/program/steps/addressbook/export.inc
index 1f4f11936..69f8e2e0b 100644
--- a/program/steps/addressbook/export.inc
+++ b/program/steps/addressbook/export.inc
@@ -32,7 +32,7 @@ header('Content-Disposition: attachment; filename="rcube_contacts.vcf"');
while ($result && ($row = $result->next())) {
// we already have a vcard record
if ($row['vcard']) {
- echo $row['vcard'] . "\n";
+ echo rcube_vcard::rfc2425_fold($row['vcard']) . "\n";
}
// copy values into vcard object
else {
@@ -46,7 +46,7 @@ while ($result && ($row = $result->next())) {
}
}
- echo $vcard->export() . "\n";
+ echo $vcard->export(true) . "\n";
}
}