Bug 317966 - Invalid interpretation of 'X-KADDRESSBOOK-…' (case sensitive?)
Summary: Invalid interpretation of 'X-KADDRESSBOOK-…' (case sensitive?)
Status: CONFIRMED
Alias: None
Product: kaddressbook
Classification: Applications
Component: general (show other bugs)
Version: 5.3.0
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 317767 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-04-07 06:20 UTC by Bernhard Scheirle
Modified: 2017-05-22 05:51 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
The test .vcf (628 bytes, application/octet-stream)
2013-04-07 06:21 UTC, Bernhard Scheirle
Details
Uppercase form of the test .vcf (628 bytes, application/octet-stream)
2013-04-07 06:34 UTC, Bernhard Scheirle
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard Scheirle 2013-04-07 06:20:58 UTC
Some of the X-KADDRESSBOOK entries are not interpreted correctly after syncing with ownCloud.

OwnCloud transforms all X-KADDRESSBOOK entries into uppercase form.
And therefore some of them are unknown.

Invalid interpretation:
X-KADDRESSBOOK-BLOGFEED
X-KADDRESSBOOK-MAILALLOWTOREMOTECONTENT
X-KADDRESSBOOK-MAILPREFEREDFORMATTING
X-KADDRESSBOOK-X-ANNIVERSARY
X-KADDRESSBOOK-X-ASSISTANTSNAME
X-KADDRESSBOOK-X-MANAGERSNAME
X-KADDRESSBOOK-X-OFFICE
X-KADDRESSBOOK-X-PROFESSION
X-KADDRESSBOOK-X-SPOUSESNAME

Valid interpretation:
X-KADDRESSBOOK-CRYPTOENCRYPTPREF
X-KADDRESSBOOK-CRYPTOPROTOPREF
X-KADDRESSBOOK-CRYPTOSIGNPREF
X-KADDRESSBOOK-OPENPGPFP

Reproducible: Always

Steps to Reproduce:
1. Imort the given .vcf
2. Sync it with ownCloud
3. Resync your address book
4. Only if the contact gets deleted: Restart the resource (see: https://bugs.kde.org/show_bug.cgi?id=317767#c9 )
Actual Results:  
The above listed X-KADDRESSBOOK entries are not interpreted correctly and therefore are listed in "Custom Fields" without the X-KADDRESSBOOK prefix.
Except for X-KADDRESSBOOK-X-ANNIVERSARY, it's not visible at all.

Expected Results:  
They should be interpreted correctly and the content should be visible in the given textboxes.

KDE: 4.10.2
Comment 1 Bernhard Scheirle 2013-04-07 06:21:42 UTC
Created attachment 78695 [details]
The test .vcf
Comment 2 Bernhard Scheirle 2013-04-07 06:33:15 UTC
Well, you can also just import the uppercase form of the .vcf
It leads to the same result.
Comment 3 Bernhard Scheirle 2013-04-07 06:34:37 UTC
Created attachment 78696 [details]
Uppercase form of the test .vcf

just import this file to see the bug
Comment 4 Bernhard Scheirle 2013-04-07 06:44:08 UTC
Seems to be the same bug as here ( Bug 307618 - parsing problem with anniversary property converted to upper case ).
Just some more fields.
Comment 5 Bernhard Scheirle 2013-04-07 07:48:55 UTC
This could fix this issue. 

BUT be carefull it is not tested!

What did I do?:
- I followed the fix in Bug 307618 .
- X-Profession is removed because it is already in the set.
- Added the upper case version of every key

diff --git a/akonadi/contact/editor/customfieldseditwidget.cpp b/akonadi/contact/editor/customfieldseditwidget.cpp
index dc0cc6c..c4d1e00 100644
--- a/akonadi/contact/editor/customfieldseditwidget.cpp
+++ b/akonadi/contact/editor/customfieldseditwidget.cpp
@@ -120,9 +120,7 @@ void CustomFieldsEditWidget::loadContact( const KABC::Addressee &contact )
                       << QLatin1String( "X-ManagersName" )
                       << QLatin1String( "X-AssistantsName" )
                       << QLatin1String( "X-Anniversary" )
-                      << QLatin1String( "X-ANNIVERSARY" )
                       << QLatin1String( "X-SpousesName" )
-                      << QLatin1String( "X-Profession" )
                       << QLatin1String( "MailPreferedFormatting")
                       << QLatin1String( "MailAllowToRemoteContent")
                       << QLatin1String( "CRYPTOPROTOPREF" )
@@ -130,6 +128,11 @@ void CustomFieldsEditWidget::loadContact( const KABC::Addressee &contact )
                       << QLatin1String( "SMIMEFP" )
                       << QLatin1String( "CRYPTOSIGNPREF" )
                       << QLatin1String( "CRYPTOENCRYPTPREF" );
+            QSet<QString> upperCaseBlacklist;
+            foreach(const QString& blacklistEntry, blacklist) {
+              upperCaseBlacklist << blacklistEntry.toUpper();
+            }
+            blacklist.unite(upperCaseBlacklist);
         }
 
       if ( blacklist.contains( name ) ) { // several KAddressBook specific fields
diff --git a/akonadi/contact/standardcontactformatter.cpp b/akonadi/contact/standardcontactformatter.cpp
index 8bbdb5f..0acc23d 100644
--- a/akonadi/contact/standardcontactformatter.cpp
+++ b/akonadi/contact/standardcontactformatter.cpp
@@ -214,6 +214,13 @@ QString StandardContactFormatter::toHtml( HtmlForm form ) const
     titleMap.insert( QLatin1String( "IMAddress" ), i18n( "IM Address" ) );
     titleMap.insert( QLatin1String( "Anniversary" ), i18n( "Anniversary" ) );
     titleMap.insert( QLatin1String( "AddressBook" ), i18n( "Address Book" ) );
+    QMap<QString, QString> upperCaseTitleMap;
+    QMap<QString, QString>::const_iterator iterator = titleMap.constBegin();
+    while (iterator != titleMap.constEnd()) {
+      upperCaseTitleMap.insert(iterator.key().toUpper(), iterator.value());
+      ++iterator;
+    }
+    titleMap.unite(upperCaseTitleMap);
   }
 
   static QSet<QString> blacklistedKeys;
@@ -242,7 +249,7 @@ QString StandardContactFormatter::toHtml( HtmlForm form ) const
         if ( key == QLatin1String( "Anniversary" ) || key == QLatin1String( "ANNIVERSARY" ) ) {
           const QDateTime dateTime = QDateTime::fromString( value, Qt::ISODate );
           value = KGlobal::locale()->formatDate( dateTime.date() );
-        } else if ( key == QLatin1String( "BlogFeed" ) ) {  // blog is handled separated
+        } else if ( key == QLatin1String( "BlogFeed" ) || key == QLatin1String( "BLOGFEED" ) ) {  // blog is handled separated
           continue;
         } else if ( blacklistedKeys.contains( key ) ) {
           continue;
Comment 6 Grégory Oestreicher 2013-04-07 07:50:56 UTC
I've tested with the first version of your test file and the latest of 4.10 in the Git repo and the issue is not present (ownCloud does not uppercases the fields). I've changed a bit the way contacts are imported, so that may explain and in that case the issue seems to be in the VCard converter.

However with your second test file the problem arises. Which client generated this file? Is it with the DAV resource only?
Comment 7 Bernhard Scheirle 2013-04-07 08:02:16 UTC
(In reply to comment #6)
> (ownCloud does not uppercases the fields).
Well, in my ownCloud mySQL Database the fields are all uppercase.

> However with your second test file the problem arises. Which client
> generated this file?
I simply exported the contact after the resync. (And removed one ownCloud specific line. (PRODID:-//ownCloud//NONSGML Contacts 0.2.5//EN))

> Is it with the DAV resource only?
With the second test file, no.
Comment 8 Grégory Oestreicher 2013-04-07 08:10:17 UTC
(In reply to comment #7)
> (In reply to comment #6)
> > (ownCloud does not uppercases the fields).
> Well, in my ownCloud mySQL Database the fields are all uppercase.

Ah, right, the bug fix came in the way :) Changing a bit the contact in ownCloud and refreshing it did the trick.

I'm re-assigning to the right product.
Comment 9 Bernhard Scheirle 2013-04-07 08:22:48 UTC
I forgot two lines in the fix above:


@@ -224,6 +231,8 @@ QString StandardContactFormatter::toHtml( HtmlForm form ) const
     blacklistedKeys.insert( QLatin1String( "CRYPTOSIGNPREF" ) );
     blacklistedKeys.insert( QLatin1String( "CRYPTOENCRYPTPREF" ) );
     blacklistedKeys.insert( QLatin1String( "MailPreferedFormatting" ) );
+    blacklistedKeys.insert( QLatin1String( "MAILPREFEREDFORMATTING" ) );
+    blacklistedKeys.insert( QLatin1String( "MAILALLOWTOREMOTECONTENT" ) );
     blacklistedKeys.insert( QLatin1String( "MailAllowToRemoteContent" ) );
   }
Comment 10 Grégory Oestreicher 2013-04-22 19:23:33 UTC
*** Bug 317767 has been marked as a duplicate of this bug. ***
Comment 11 m.wege 2013-04-22 20:14:28 UTC
Would be cool, if this fix made it into KDE 4.10.3.
Comment 12 Grégory Oestreicher 2013-04-23 20:00:43 UTC
Bernhard,

Have you tested your patch? If so, does it work as intended? I'm still a bit worried about the "BUT be carefull it is not tested!" part in comment #5 :)

If you're satisfied with it I can ask for a first informal review on the kde-pim@kde.org mailing list, but it's better if you can confirm that it's at least working for you.

Cheers,
Grégory
Comment 13 m.wege 2013-04-24 17:29:50 UTC
Can someone give instructions how to compile it with this patch. Then I am willing to test it :-)
Comment 14 m.wege 2013-04-27 10:19:22 UTC
So, i somehow tested this patch by modifying the compilation instruction you gave me in the other bug and handediting the above patch into the files. Everything went through fine. It appears to work, I could not find any problems of information put into custom fields. Although the problem still remains that only a part of the contacts shown in Owncloud are shown in Kaddressbook. I am not sure if this is related. I will file another bug
Comment 15 Stéphane Pontier 2015-06-05 12:27:55 UTC
Is this patch supposedly applied? I have the same problem of case sensitivity on X-KADDRESSBOOK-X-PROFESSION with kmail/akonadi 2.14.7 and owncloud 8.0.3
Comment 16 Denis Kurz 2016-09-24 20:56:23 UTC
This bug has only been reported for versions before 4.14, which have been unsupported for at least two years now. Can anyone tell if this bug still present?

If noone confirms this bug for a Framework-based version of kdepim (version 5.0 or later, as part of KDE Applications 15.08 or later), it gets closed in about three months.
Comment 17 Bernhard Scheirle 2016-09-25 05:35:10 UTC
This is still present / reproducible in KAddressBook 5.3.0.

KDE Neon
KDE Frameworks 5.26.0 
Qt 5.7.0 (kompiliert gegen 5.7.0) 
Das xcb Fenstersystem
Comment 18 Laurent Montel 2017-05-22 05:51:21 UTC
Git commit e39302f6b69c816b6f0208e3ce2f6672f340b43c by Montel Laurent.
Committed on 22/05/2017 at 05:50.
Pushed by mlaurent into branch 'master'.

Start to look at Bug 317966. Apply patch in this bug report

M  +5    -3    src/editor/customfieldeditor/customfieldslistwidget.cpp
M  +11   -1    src/standardcontactformatter.cpp

https://commits.kde.org/akonadi-contacts/e39302f6b69c816b6f0208e3ce2f6672f340b43c