Bug 293098 - KAddressbook/Akonadi stores CATEGORIES escaped the wrong way
Summary: KAddressbook/Akonadi stores CATEGORIES escaped the wrong way
Status: RESOLVED FIXED
Alias: None
Product: kaddressbook
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR major
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-01 23:24 UTC by Ingo Ratsdorf
Modified: 2012-06-29 09:05 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.8.5


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ingo Ratsdorf 2012-02-01 23:24:16 UTC
Version:           unspecified (using KDE 4.7.4) 
OS:                Linux

The internal storage of VCARDS in Akonadi is incorrect regarding multiple CATEGORIES.
Categories are stored in VCARD data like this:

CATEGORIES:CatA\,CatB\,Cat C,D,E\,CatF

whereas according to the RFC, they should be rather stored like that:

CATEGORIES:CatA,CatB,Cat C\,D\,E,CatF

Reproducible: Always

Steps to Reproduce:
Create a contact with multiple categories, sync via groupdav and watch VCARD sent or jut watch raw storage in Akonadi Console

Actual Results:  
CATEGORIES will be joined together with "\," instaed of just ","

Expected Results:  
CATEGORIES should be joined together just with "," and all "," WITHIN a categories should be escaped with "\,".

This bug causes LOSS OF DATA , ie CATEGORIES and messes up the DAV server

Reference:
http://tools.ietf.org/html/rfc6350#section-4
http://tools.ietf.org/html/rfc6350#section-6.7.1

text = *TEXT-CHAR
TEXT-CHAR = "\\" / "\," / "\n" / WSP / NON-ASCII
               / %x21-2B / %x2D-5B / %x5D-7E
; Backslashes, commas, and newlines must be encoded.

text-list             = text             *("," text)

CATEGORIES-value = text-list

Example:
CATEGORIES:INTERNET,IETF,INDUSTRY,INFORMATION TECHNOLOGY

NOTE in the above that special chars WITHIN the category must be encoded, but the individual categories are joined together using plain ","
Comment 1 Dean Cording 2012-02-09 13:48:58 UTC
*** This bug has been confirmed by popular vote. ***
Comment 2 Heiner Markert 2012-03-13 15:14:26 UTC
I am also experiencing this bug.
Also exported vCard 3.0 files are broken.
This bug can already be seen in Kontact from KDE 3.5.10 (with export to vCard, DAV was not supported at that time), so it seems to be a pretty old defect...
Comment 3 Ingo Ratsdorf 2012-05-31 09:09:34 UTC
This is a bug in the underlaying iCal library. Anybody working on this one?
Comment 4 Ingo Ratsdorf 2012-05-31 09:17:52 UTC
After upgrading to 4.8.3, the bug seems to be resolved.
Comment 5 Andreas Dick 2012-05-31 21:03:29 UTC
Hei Ingo
how did you have tested this?

I have just installed 4.8.3 on my Kubuntu 12.4
then I created just a simple addressbook (as plain file)
then I exported a dummy contact to as VCARD 3.0:
------------------------------------------
BEGIN:VCARD
CATEGORIES:Friends\,Familie
FN:Blabla
N:Blabla;;;;
UID:z3HxtI38VK
VERSION:3.0
END:VCARD
-------------------------------------------
thus, the group seperator is still wrong for me: \,

Using the GroupDAV connector with SabreDAV is doing the same, but testing with  the vcf3.0 export is a faster check

Andreas
Comment 6 Ingo Ratsdorf 2012-05-31 22:14:37 UTC
Hmm, strange. I did a sync via CardDAV using the groupdav resource and traced conversation using WireShark. And all was fine, only commas ",", without the backslashes "\,"...
So sync was perfect.
Is the akonadi groupdav resource maybe changing the encoding before it sends it? And KAddressbook is using the original iCal library to export? Remember the export is not done by Akonadi or it's resources...
Comment 7 Ingo Ratsdorf 2012-06-01 04:08:31 UTC
Sorry, my wrong. KOrganiser does sync calendar CATEGORIES now correctly, but KAddressbook is still doing it wrong. And it still does not sync or export FBURL.
Strange bug. It stores it incorrectly in Akonadi, so I guess it's not a bug in KAddressbook but in one of the underlaying libs. One of the bugs in KAddressbook re birthday display has recently been resolved.
I'll dig a bit in the git repos to find the origin.
Comment 8 Ingo Ratsdorf 2012-06-01 05:09:09 UTC
vcardtool assumes that categories are stored in a QStringList:

creating VCard data

142	    if ( version == VCard::v3_0 ) {
143	      QStringList categories = (*addrIt).categories();
144	      QStringList::Iterator catIt;
145	      for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
146	        (*catIt).replace( QLatin1Char( ',' ), QLatin1String( "\\," ) );
147	      }
148	
149	      VCardLine catLine( QLatin1String( "CATEGORIES" ), categories.join( QLatin1String( "," ) ) );
150	      card.addLine( catLine );
151	    }

The code seems to be okay. It replaces all commas within each string (category) with '\,' which is correct.
It then joins it all together using plain ','.
This is according to RFC

parsing VCard Data

364	  static const QLatin1Char commaSep( ',' );

428	        else if ( identifier == QLatin1String( "categories" ) ) {
429	          const QStringList categories = splitString( commaSep, (*lineIt).value().toString() );
430	          addr.setCategories( categories );
431	        }

Addr is apparently defined in kabc/addressee.cpp, however I cannot find that file!!!

=====================

ASSUMPTION: KAddressbook or underlaying packages are not using QStringlist but store one single CATEGORIES string in QStringlist,
hence all commas within are replaced.

Does that make sense to anyone?
Comment 9 Ingo Ratsdorf 2012-06-26 19:11:13 UTC
Hard to believe that nobody else is bothered by this bug and that no one seems to put any effort into fixing it.
Is anybody reading this out there?

If the source code would be better documented or I could actually FIND the files, I could hunt for myself!

Disappointing really!
Comment 10 Andreas Dick 2012-06-26 20:13:58 UTC
I agree!
thanks so far...
Andreas

Am Dienstag, 26. Juni 2012, 19.11:13 schrieben Sie:
> https://bugs.kde.org/show_bug.cgi?id=293098
> 
> --- Comment #9 from Ingo Ratsdorf <ingo@envirology.co.nz> ---
> Hard to believe that nobody else is bothered by this bug and that no one
> seems to put any effort into fixing it.
> Is anybody reading this out there?
> 
> If the source code would be better documented or I could actually FIND the
> files, I could hunt for myself!
> 
> Disappointing really!
Comment 11 Laurent Montel 2012-06-29 07:50:58 UTC
I confirm it.
Will look at how to fix it.
Comment 12 Laurent Montel 2012-06-29 08:23:30 UTC
Git commit 51a474722ee0d5b96e2e5593978bc5be3deef516 by Montel Laurent.
Committed on 29/06/2012 at 10:22.
Pushed by mlaurent into branch 'master'.

Fix Bug 293098 - KAddressbook/Akonadi stores CATEGORIES escaped the

wrong way

It was already escaped when we create category
Not necessary to re-escapte it.
FIXED-IN: 4.8.5

M  +4    -4    kabc/vcardparser/vcardparser.cpp

http://commits.kde.org/kdepimlibs/51a474722ee0d5b96e2e5593978bc5be3deef516
Comment 13 Laurent Montel 2012-06-29 08:23:59 UTC
Git commit e2fe3f314d5ab5665e87e6e9b5b8ba268ada90f9 by Montel Laurent.
Committed on 29/06/2012 at 10:22.
Pushed by mlaurent into branch 'KDE/4.8'.

Fix Bug 293098 - KAddressbook/Akonadi stores CATEGORIES escaped the

wrong way

It was already escaped when we create category
Not necessary to re-escapte it.
FIXED-IN: 4.8.5
(cherry picked from commit 51a474722ee0d5b96e2e5593978bc5be3deef516)

M  +4    -4    kabc/vcardparser/vcardparser.cpp

http://commits.kde.org/kdepimlibs/e2fe3f314d5ab5665e87e6e9b5b8ba268ada90f9
Comment 14 Laurent Montel 2012-06-29 08:25:42 UTC
Git commit 688dc4c1c61cfc90308c25c4b5e9213d3263c8f4 by Montel Laurent.
Committed on 29/06/2012 at 10:22.
Pushed by mlaurent into branch 'KDE/4.9'.

Fix Bug 293098 - KAddressbook/Akonadi stores CATEGORIES escaped the

wrong way

It was already escaped when we create category
Not necessary to re-escapte it.
FIXED-IN: 4.8.5
(cherry picked from commit 51a474722ee0d5b96e2e5593978bc5be3deef516)

M  +4    -4    kabc/vcardparser/vcardparser.cpp

http://commits.kde.org/kdepimlibs/688dc4c1c61cfc90308c25c4b5e9213d3263c8f4
Comment 15 Ingo Ratsdorf 2012-06-29 08:57:27 UTC
Supercool! If that solved the issue, that would be fantastic.
Thanks!
Comment 16 Laurent Montel 2012-06-29 09:05:34 UTC
For me it's ok now. Please test it:)