Bug 297541 - kaddressbook doesn't handle line breaks correctly in the notes field.
Summary: kaddressbook doesn't handle line breaks correctly in the notes field.
Status: RESOLVED FIXED
Alias: None
Product: kaddressbook
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Platform: Archlinux Packages Linux
: NOR normal with 20 votes (vote)
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-05 15:43 UTC by Divan Santana
Modified: 2012-04-24 16:18 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.8.3


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Divan Santana 2012-04-05 15:43:26 UTC
SUMMARY
If one creates a contact on a platform that creates a contact with the notes field filled in as per below syntax:
$ cat Firstname_Surname.vcf 
BEGIN:VCARD
EMAIL:"Firstname Surname" <Firstname.Surname@example.org>
FN:Firstname Surname
N:Surname;Firstname;;;
NOTE:This is line one of the notes field\\NThis is line two of the notes fi
 eld\\NThis is line three of the notes field
UID:8e548460-3843-4e39-9d71-19c7dad93864:521756
VERSION:3.0
END:VCARD

Then it doesn't correctly display the line breaks.

STEPS TO REPRODUCE
1. Create a contact with the notes field populated as per:
NOTE:This is line one of the notes field\\NThis is line two of the notes fi
 eld\\NThis is line three of the notes field

Instead of the norm(whatever that is):
One can do this by
a) An Android phone syncing with Kontact via Zimbra
b) create the contact on a groupware server like Zimbra
or rather (and ease to reproduce this problem)
c) Simply import a contact formulated in this manner.
Import this contact:
$ cat Firstname_Surname.vcf 
BEGIN:VCARD
EMAIL:"Firstname Surname" <Firstname.Surname@example.org>
FN:Firstname Surname
N:Surname;Firstname;;;
NOTE:This is line one of the notes field\\NThis is line two of the notes fi
 eld\\NThis is line three of the notes field
UID:8e548460-3843-4e39-9d71-19c7dad93864:521756
VERSION:3.0
END:VCARD

WHAT HAPPENS
2. View this contact in kaddress book. You notice the notes field is not nicely displayed in kaddressbook search view. Rather you see 

Notes
This is line one of the notes field\NThis is line two of the notes field\NThis is line three of the notes field

WHAT SHOULD HAPPENS
2. View this contact in kaddress book. You notice the notes field is nicely displayed in kaddressbook search view. You see 
This is line one of the notes field
This is line two of the notes field
This is line three of the notes field
Comment 1 Divan Santana 2012-04-07 19:26:07 UTC
As per discussion here: http://lists.kde.org/?t=133379575800003&r=1&w=2

After further investigation it seems the problem is possibly in the vcard parser.
When exporting the problematic contact it uses the \N CRLF character sequence which is valid according to the RFC:
https://www.ietf.org/rfc/rfc2426.txt

$ cat Downloads/Lastname\,\ Firstname.vcf 
BEGIN:VCARD
VERSION:3.0
FN:Lastname\, Firstname
N:Lastname;Firstname;;;
EMAIL;TYPE=internet:firstname@lastname.org
NOTE:This is line one of the notes section\NThis is line two of the notes section\NThis is line three of the notes section\NThis is line four of the notes section
REV:2012-04-05T23:09:44Z
UID:8e548460-3843-4e39-9d71-19c7dad93864:522525
END:VCARD
Comment 2 Kevin Krammer 2012-04-12 16:46:42 UTC
Just to update: I have most likely found a fix for that but the commit will have to wait until someone with more knowledge about the internals of the changed code has had time to verify that there are not bad consequences.

https://git.reviewboard.kde.org/r/104509/
Comment 3 Kevin Krammer 2012-04-13 09:35:15 UTC
Quick question: does Zimbra handle vcards with \n properly?
I.e. if you create a new contact with multiline notes in KAddressBook and save it to the Zimbra server, does its web interface and your Android phone display that correctly?
Comment 4 Divan Santana 2012-04-13 21:52:14 UTC
Well I create a contact in KAddressBook now and in the notes field put:
This is line one
This is line two
This is line three
This is line four

I sync with zimbra.
Zimbra and Android phone display the notes field correctly.
However, I then from zimbra web interface email the contact from addressbook as VCF and below is the result:
$ cat Downloads/Testing\ Contact.vcf 
BEGIN:VCARD
VERSION:3.0
FN:Testing Contact
N:Contact;Testing;;;
NOTE:This is line one\NThis is line two\NThis is line three\NThis is line four
REV:2012-04-13T23:46:31Z
UID:PdJOY3AP9k
END:VCARD

Perhaps Zimbra auto converts it to \N from \n .
I hope the patch is allowed through and addresses it, it will make kaddressbook syncing with latest Zimbra server work just fine.
Comment 5 Divan Santana 2012-04-14 10:36:53 UTC
KDE devs, I can provide a Zimbra account for testing without a problem or any other information needed to help. Thanks for the efforts.
Comment 6 Kevin Krammer 2012-04-24 16:18:29 UTC
Git commit d0f37e740e1715d7b0228da9912a43db8051fde6 by Kevin Krammer.
Committed on 07/04/2012 at 22:07.
Pushed by krake into branch 'KDE/4.8'.

Treat \N as a valid new line sequence in vcard input

The vCard RFC has a note on fields of type text that suggests that
both \n and \N are to be treated as new line sequences:

        . The method for specifying CRLF character sequences in text
          type values has been changed. The CRLF character sequence in
          a text type value is specified with the backslash character
          sequence "\n" or "\N".

Backport of f7a29b54327876508e834c407173084e0f626252
FIXED-IN: 4.8.3
REVIEW: 104509

A  +8    -0    kabc/vcardparser/tests/vcard8.vcf
A  +8    -0    kabc/vcardparser/tests/vcard8.vcf.ref
M  +1    -0    kabc/vcardparser/vcardparser.cpp

http://commits.kde.org/kdepimlibs/d0f37e740e1715d7b0228da9912a43db8051fde6
Comment 7 Kevin Krammer 2012-04-24 16:18:58 UTC
Git commit f7a29b54327876508e834c407173084e0f626252 by Kevin Krammer.
Committed on 07/04/2012 at 22:07.
Pushed by krake into branch 'master'.

Treat \N as a valid new line sequence in vcard input

The vCard RFC has a note on fields of type text that suggests that
both \n and \N are to be treated as new line sequences:

        . The method for specifying CRLF character sequences in text
          type values has been changed. The CRLF character sequence in
          a text type value is specified with the backslash character
          sequence "\n" or "\N".
FIXED-IN: 4.8.3
REVIEW: 104509

M  +2    -0    kabc/vcardparser/testroundtrip.qrc
A  +8    -0    kabc/vcardparser/tests/vcard8.vcf
A  +8    -0    kabc/vcardparser/tests/vcard8.vcf.ref
M  +1    -0    kabc/vcardparser/vcardparser.cpp

http://commits.kde.org/kdepimlibs/f7a29b54327876508e834c407173084e0f626252