[RCD] Line endings in vCard format

Eric Mason eric at equisolve.com
Thu Jul 21 18:27:06 CEST 2011


I had a Windows user tell me her exports from vCard were only giving her
every other line.  I noticed RoundCube's vcf file had only LFs for line
endings, but the vCard standard seems to specify CRLF -
http://www.imc.org/pdi/vcard-21.txt .  After adding the CRs to the VCF the
file imports fine.

After a quick search/replace of \n to \r\n in rcube_vcard.php the vCards are
importing correctly. I tried to be smart about it but it may not be 100%
correct. :)


diff orig/roundcubemail-0.5.3/program/include/rcube_vcard.php
./roundcubemail-0.5.3/program/include/rcube_vcard.php
229c229
<         $vcard_block .= $line . "\n";
---
>         $vcard_block .= $line . "\r\n";
242c242
<         $vcard_block = $line . "\n";
---
>         $vcard_block = $line . "\r\n";
266c266
<     $vcard = preg_replace(array('/^item\d*\.X-AB.*$/m', '/^item\d*\./m',
"/\n+/"), array('', '', "\n"), $vcard);
---
>     $vcard = preg_replace(array('/^item\d*\.X-AB.*$/m', '/^item\d*\./m',
"/\n+/"), array('', '', "\r\n"), $vcard);
281c281
<     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) . "\r\n";
321c321
<                   $line[2] .= "\n" . $lines[++$i];
---
>                   $line[2] .= "\r\n" . $lines[++$i];
421c421
<         $vcard .= self::vcard_quote($type) . $attr . ':' .
self::vcard_quote($value) . "\n";
---
>         $vcard .= self::vcard_quote($type) . $attr . ':' .
self::vcard_quote($value) . "\r\n";
425c425
<     return "BEGIN:VCARD\nVERSION:3.0\n{$vcard}END:VCARD";
---
>     return "BEGIN:VCARD\r\nVERSION:3.0\r\n{$vcard}END:VCARD";
445c445
<       return strtr($s, array('\\' => '\\\\', "\r" => '', "\n" => '\n', ';'
=> '\;', ':' => '\:'));
---
>       return strtr($s, array('\\' => '\\\\', "\n" => '\n', ';' => '\;',
':' => '\:'));


[image: Equisolve] <http://www.equisolve.com/>

*Eric Mason* | eric at equisolve.com | www.equisolve.com
Phone: 954-390-6060 ext. 108 | Fax: 954-756-7536
2455 E Sunrise Blvd Ste 1201, Fort Lauderdale, FL 33304
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.roundcube.net/pipermail/dev/attachments/20110721/e88135b5/attachment.html>
-------------- next part --------------
_______________________________________________
List info: http://lists.roundcube.net/dev/
BT/aba52c80


More information about the Dev mailing list