Bug 172764 - Vcard export: Windows newlines
Summary: Vcard export: Windows newlines
Status: RESOLVED UNMAINTAINED
Alias: None
Product: kab3
Classification: Miscellaneous
Component: general (show other bugs)
Version: 4.1
Platform: Ubuntu Unspecified
: NOR wishlist
Target Milestone: ---
Assignee: Tobias Koenig
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-14 01:35 UTC by Dotan Cohen
Modified: 2009-08-05 16:38 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Vcard file from Kaddressbook 3.5.10 (174 bytes, text/vcard)
2008-10-14 21:15 UTC, Dotan Cohen
Details
Vcard file from Kaddressbook 3.5.10 (239 bytes, text/vcard)
2008-10-15 21:28 UTC, Dotan Cohen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dotan Cohen 2008-10-14 01:35:44 UTC
Version:            (using KDE 4.1.1)
Installed from:    Ubuntu Packages

When exporting vcards it would be nice if there were an option to write Windows newlines (\r\n) instead of Linux newlines (\n). This would save a step (newline conversion) for the all-too-common task of moving data between systems.
Comment 1 Tobias Koenig 2008-10-14 19:41:24 UTC
Hej,

KAddressBook in KDE 3.5 and KDE 4.X always export vCards with \r\n as it
is requested by the vCard standard.
Comment 2 Dotan Cohen 2008-10-14 21:15:29 UTC
Created attachment 27882 [details]
Vcard file from Kaddressbook 3.5.10

I am leaving this INVALID on the assumption that you are correct, but this is what Kaddressbook 3.5.10 on KDE 3 gave me. KDE 4.x gave something similar. To me it looks like \n, can you confirm that it is in fact \n\r?
Comment 3 Dotan Cohen 2008-10-15 09:39:42 UTC
I see the problem now: there are two types of newlines in these vcard files:
1) The newlines for the linewrapping, which are in fact /n/r as the spec specifies
2) The newlines for the content (where the user enters a newline in Kaddressbook fields). These are _not_ /n/r which can clearly be seen by opening the attached file from the previous comment in a text editor, or better yet, by importing them in any Windows-based vcard-compliant system.

Reopening.
Comment 4 Tobias Koenig 2008-10-15 20:04:04 UTC
Hej,

ahh ok, that explains it ;)
However I have no influence on it, KAddressBook just calls QTextEdit::toPlainText(), which
returns line ends as '\n' and I won't implement any magic to replace it, as there are
several cases where that goes wrong... so no wish list that might create new bugs, sorry.
Comment 5 Dotan Cohen 2008-10-15 21:28:44 UTC
Created attachment 27917 [details]
Vcard file from Kaddressbook 3.5.10

That is pretty bad, as Kontact is not Vcard compliant. Could you file a Qt bug, then? I would file it but I am not as knowledgeable in the field.



Attached is a test vcard file. This file has this Notes Field in Kaddressbook:
-----
First Line.
The Second Line is long so that it will wrap. Long, long, and wrapping!
Third Line.

-----



This is how it appears when imported directly into a WM2003SE device:
-----
First Line.nThe Second Line i s long so that it will wrap. Long, long, and wrapping!nThird Line.n
-----



You can see two errors there:
1) The \n characters are shown instead of giving a new line.
2) There is a space in the word "is" where the line wrapped.

These two conditions wreck havoc on quoted-printable text, rendering them terribly corrupted. This is a serious bug that leads to data corruption for quoted-printable text.
Comment 6 Dotan Cohen 2008-11-12 22:13:50 UTC
Tobias, could you file a bug at Trolltech regarding the issue? I really need vCard export capability.
Comment 7 Andy Nichols 2008-11-13 15:24:24 UTC
This is not a bug with Qt.  When toPlainText() is called eventually the following method is called:
QString QTextDocument::toPlainText() const
{
    Q_D(const QTextDocument);
    QString txt = d->plainText();
    txt.replace(QTextBeginningOfFrame, QLatin1Char('\n'));
    txt.replace(QTextEndOfFrame, QLatin1Char('\n'));
    txt.replace(QChar::ParagraphSeparator, QLatin1Char('\n'));
    txt.replace(QChar::LineSeparator, QLatin1Char('\n'));
    txt.replace(QChar::Nbsp, QLatin1Char(' '));
    return txt;
}

Just call the appropriate QString::replace(...) commands on the QString returned by QTextEdit::toPlainText().  It's not something that's going to get changed in Qt.
Comment 8 Dotan Cohen 2008-12-11 10:54:31 UTC
In light of Andy's discovery, I am reopening the bug. Thanks!
Comment 9 Dotan Cohen 2009-08-03 16:04:48 UTC
Since Andy found the problem, can this be fixed?
Comment 10 Tobias Koenig 2009-08-05 16:38:29 UTC
The development of the old KAddressBook will be discontinued for KDE 4.4.
Since the new application has the same name, but a completly new code base we close all bug reports against the old version and ask the submitters to resend there reports against the new product.