Opened 5 years ago

Closed 4 years ago

#1485448 closed Bugs (wontfix)

VCards from OSX address book with UTF-16 not importing

Reported by: dynedain Owned by:
Priority: 8 Milestone: 0.3.1
Component: Addressbook Version: git-master
Severity: normal Keywords: vcard contact address book
Cc:

Description

When importing VCards, Roundcube chokes on VCards generated by the OSX address book. This causes Roundcube to think the VCard is invalid.

I suspect that this has something to do with Mac end-of-line characters being present in the file. I opened the VCard with a text-editor and resaved using standard UNIX end of line characters and the file then imported properly. There isn't a problem with actual contents as I didn't modify the data.

Attachments (1)

1485448 Patch.txt (1.1 KB) - added by dynedain 5 years ago.
Patch

Download all attachments as: .zip

Change History (13)

comment:1 Changed 5 years ago by dynedain

From a bit of research comparing the file originally exported by the OSX address book app, it appears that the file is encoded as UTF-16BE.

Some more testing... I tried modifying line 174 of rcube_vcard.php to force roundcube to be converting from UTF-16BE and the import worked! So my next guess is that roundcube is not properly detecting that the VCard is UTF-16BE encoded.

comment:2 Changed 5 years ago by dynedain

A little more info as I try to track this down... the detect_encoding function in rcube_vcard is not detecting UTF-16BE by xFE\xFF on this VCard (not sure why) and so is reverting to rc_detect_encoding from rcube_shared.inc.

Apparently mb_detect_encoding() can't detect UTF-16BE http://bugs.php.net/bug.php?id=45993 so the rc_detect_encoding() wrapper is returning the wrong result.

I don't know if there's a performance hit to replacing it with mb_check_encoding($string, 'UTF-16BE') but it might be workaround.

comment:3 Changed 5 years ago by dynedain

  • Milestone changed from later to 0.2-stable
  • Severity changed from major to normal

Some more info, UTF-16BE isn't being noticed because the first 2 characters of the filestream from file_get_contents() do not match \xFE\xFF. Why this is, I don't know. I'm at my wits end as file encoding is all new to me.

Changed 5 years ago by dynedain

Patch

comment:4 Changed 5 years ago by dynedain

I've created a patch for rcube_vcard that adds md_check_encoding() functions to test for UTF-16 encoding. I don't know if it is sufficient as conceivably other encoding types could produce false positives.

comment:5 Changed 5 years ago by alec

Please, attach sample vcard file in utf-16 for testing.

comment:6 Changed 5 years ago by dynedain

I'm having trouble generating a VCard that exhibits the problem. The VCard I do have that generates the issue I cannot share because of private data and I'm worried that anonimizing it may cause re-encoding.

I'll see what I can do.

comment:7 Changed 5 years ago by thomasb

mb_check_encoding($string,'UTF-16BE') wrongly detects ISO-8859-1 files as UTF-16 :-(

comment:8 Changed 4 years ago by chadm

This will probably be difficult to figure out with mb_* functions. mb_detect_encoding's return is nothing more than an educated guess using heuristics. and mb_check_encoding just checks if the string can pass as the specified encoding.

It really really blows that Vcard specification doesn't require some sort of data as what the encoding is.

comment:9 in reply to: ↑ description Changed 4 years ago by questionman

Replying to dynedain:

When importing VCards, Roundcube chokes on VCards generated by the OSX address book. This causes Roundcube to think the VCard is invalid.

I suspect that this has something to do with Mac end-of-line characters being present in the file. I opened the VCard with a text-editor and resaved using standard UNIX end of line characters and the file then imported properly. There isn't a problem with actual contents as I didn't modify the data.


I have Mac OSX and i can import VCards generated using Address Book. No errors.

comment:10 follow-up: Changed 4 years ago by dynedain

It's been a while now, but if I remember correctly, I was having the issue with vcards that contain multiple contacts.

comment:11 in reply to: ↑ 10 Changed 4 years ago by questionman

  • Priority changed from 2 to 8

Replying to dynedain:

It's been a while now, but if I remember correctly, I was having the issue with vcards that contain multiple contacts.

Yes. Has the error been fixed (for you)?

comment:12 Changed 4 years ago by netbit

  • Component changed from Core functionality to Addressbook
  • Resolution set to wontfix
  • Status changed from new to closed
  • Summary changed from VCards from OSX address book not importing to VCards from OSX address book with UTF-16 not importing

We need a multiple contacts sample vCard file in UTF-16 for testing. As we had no response, I'm closing this ticket. Reopen if needed.

Note: See TracTickets for help on using tickets.