summaryrefslogtreecommitdiffstats
path: root/kaddressbook
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2024-07-04 11:38:46 +0300
committerMavridis Philippe <mavridisf@gmail.com>2024-09-01 14:26:59 +0300
commit12f0bfb59cda3e1b4a88290c1bbf357d3adb46f7 (patch)
tree80b3aa69ea36add3b8317b947df0ecce9f1159af /kaddressbook
parent6f4e770e24155af7373f3f4ffb55a5f1de0847b3 (diff)
downloadtdepim-12f0bfb59cda3e1b4a88290c1bbf357d3adb46f7.tar.gz
tdepim-12f0bfb59cda3e1b4a88290c1bbf357d3adb46f7.zip
KAddressBook: Fix import encoding for vCard v4.
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
Diffstat (limited to 'kaddressbook')
-rw-r--r--kaddressbook/xxport/vcard_xxport.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/kaddressbook/xxport/vcard_xxport.cpp b/kaddressbook/xxport/vcard_xxport.cpp
index 293879cc5..6c09db006 100644
--- a/kaddressbook/xxport/vcard_xxport.cpp
+++ b/kaddressbook/xxport/vcard_xxport.cpp
@@ -239,9 +239,22 @@ TDEABC::AddresseeList VCardXXPort::importContacts( const TQString& ) const
// With version 3.0, vCards are encoded with UTF-8 by default. Otherwise, use fromLatin1()
// and hope that are fields are encoded correctly.
- if ( TQString::fromLatin1( rawData ).lower().contains( "version:3.0" ) ) {
+ bool useUtf8;
+ TQString tmp = TQString::fromLatin1(rawData).lower();
+ int ver = tmp.find("version:");
+ if (ver == -1) {
+ // no version info, assume utf8
+ useUtf8 = true;
+ }
+ else {
+ float vCardVersion = tmp.mid(ver + 8, tmp.find("\n", ver)).toFloat();
+ useUtf8 = (vCardVersion >= 3.0);
+ }
+
+ if (useUtf8) {
vCardText = TQString::fromUtf8( rawData );
- } else {
+ }
+ else {
vCardText = TQString::fromLatin1( rawData );
}
addrList += parseVCard( vCardText );