summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2012-08-17 18:37:20 (GMT)
committerChristian Mollekopf <mollekopf@kolabsys.com>2012-08-17 18:37:20 (GMT)
commit0e90a940d9bbb2b6ffa0221637a3193c07b2c216 (patch)
tree1115526594bfd1072fbd46d01913b429a22608af
parent16a3e3a53b725128a4f5065e979b15b4585e7464 (diff)
downloadlibkolab-0e90a940d9bbb2b6ffa0221637a3193c07b2c216.tar.gz
Allow for UTF-8 attachment names.
-rw-r--r--mime/mimeutils.cpp6
-rw-r--r--tests/formattest.cpp1
-rw-r--r--tests/testfiles/v2/event/attachmentUtf8.ics51
-rw-r--r--tests/testfiles/v2/event/attachmentUtf8.ics.mime107
4 files changed, 162 insertions, 3 deletions
diff --git a/mime/mimeutils.cpp b/mime/mimeutils.cpp
index a8259d3..4f913a8 100644
--- a/mime/mimeutils.cpp
+++ b/mime/mimeutils.cpp
@@ -48,7 +48,7 @@ KMime::Content* findContentByName(const KMime::Message::Ptr &data, const QString
{
Q_ASSERT(!data->contents().isEmpty());
Q_FOREACH(KMime::Content *c, data->contents()) {
-// kDebug() << "searching: " << c->contentType()->name();
+// qDebug() << "searching: " << c->contentType()->name().toUtf8();
if ( c->contentType()->name() == name ) {
type = c->contentType()->mimeType();
return c;
@@ -248,7 +248,7 @@ KMime::Content* createAttachmentPart(const QByteArray& cid, const QString& mimeT
content->contentID()->setIdentifier( cid );
}
content->contentType()->setMimeType( mimeType.toLatin1() );
- content->contentType()->setName( fileName, "us-ascii" );
+ content->contentType()->setName( fileName, "utf-8" );
content->contentTransferEncoding()->setEncoding( KMime::Headers::CEbase64 );
content->contentDisposition()->setDisposition( KMime::Headers::CDattachment );
content->contentDisposition()->setFilename( fileName );
@@ -264,7 +264,7 @@ void getAttachments(KCalCore::Incidence::Ptr incidence, const QStringList &attac
QByteArray type;
KMime::Content *content = findContentByName(mimeData, name, type);
if (!content) { // guard against malformed events with non-existent attachments
- Warning() << "could not find attachment: "<< name << type;
+ Warning() << "could not find attachment: "<< name.toUtf8() << type;
continue;
}
const QByteArray c = content->decodedContent().toBase64();
diff --git a/tests/formattest.cpp b/tests/formattest.cpp
index 4e2ee82..346c6e8 100644
--- a/tests/formattest.cpp
+++ b/tests/formattest.cpp
@@ -100,6 +100,7 @@ void FormatTest::testIncidence_data()
QTest::newRow( "v2eventComplex" ) << Kolab::KolabV2 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v2/event/complex.ics") << TESTFILEDIR+QString::fromLatin1("v2/event/complex.ics.mime");
QTest::newRow( "v2eventAttachment" ) << Kolab::KolabV2 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v2/event/attachment.ics") << TESTFILEDIR+QString::fromLatin1("v2/event/attachment.ics.mime");
QTest::newRow( "v2eventAllday" ) << Kolab::KolabV2 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v2/event/allday.ics") << TESTFILEDIR+QString::fromLatin1("v2/event/allday.ics.mime");
+ QTest::newRow( "v2eventUtf8Attachment" ) << Kolab::KolabV2 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v2/event/attachmentUtf8.ics") << TESTFILEDIR+QString::fromLatin1("v2/event/attachmentUtf8.ics.mime");
//The following test just fails because we have a nicer mime message output than horde
// QTest::newRow( "v2eventHorde" ) << Kolab::KolabV2 << Kolab::EventObject << TESTFILEDIR+QString::fromLatin1("v2/event/horde.ics") << TESTFILEDIR+QString::fromLatin1("v2/event/horde.ics.mime");
QTest::newRow( "v2todoSimple" ) << Kolab::KolabV2 << Kolab::TodoObject << TESTFILEDIR+QString::fromLatin1("v2/task/simple.ics") << TESTFILEDIR+QString::fromLatin1("v2/task/simple.ics.mime");
diff --git a/tests/testfiles/v2/event/attachmentUtf8.ics b/tests/testfiles/v2/event/attachmentUtf8.ics
new file mode 100644
index 0000000..4469d33
--- /dev/null
+++ b/tests/testfiles/v2/event/attachmentUtf8.ics
@@ -0,0 +1,51 @@
+BEGIN:VCALENDAR
+PRODID:-//K Desktop Environment//NONSGML libkcal 3.2//EN
+VERSION:2.0
+BEGIN:VEVENT
+DTSTAMP:20090901T125258Z
+ATTENDEE;CN="Attendee1";RSVP=TRUE;PARTSTAT=NEEDS-ACTION;
+ ROLE=REQ-PARTICIPANT:mailto:a1@example.com
+ATTENDEE;CN="Attendee2";RSVP=TRUE;PARTSTAT=ACCEPTED;ROLE=NON-PARTICIPANT:
+ mailto:a2@example.com
+ATTENDEE;CN="Attendee3";RSVP=FALSE;PARTSTAT=DECLINED;ROLE=REQ-PARTICIPANT:
+ mailto:a3@example.com
+CREATED:20090901T125258Z
+UID:KOrganizer-1687167952.818
+LAST-MODIFIED:20090901T125258Z
+DESCRIPTION:äöü%@$£é¤¼²°€Š�ـأبـ
+SUMMARY:äöü%@$£é¤¼²°€Š�ـأبـ
+LOCATION:äöü%@$£é¤¼²°€Š�ـأبـ
+CLASS:PRIVATE
+CATEGORIES:Appointment\,Business
+RRULE:FREQ=WEEKLY;COUNT=10;BYDAY=WE,FR
+EXDATE;VALUE=DATE:20090904
+ATTACH;VALUE=BINARY;FMTTYPE=image/png;ENCODING=BASE64;X-LABEL=äöü%@$£é¤¼²°€Š�ـأبـ:
+ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAZiS0dEAP
+ 8A/wD/oL2nkwAAAAlwSFlzAAAbrwAAG68BXhqRHAAAAAd0SU1FB9gFEQkdFPibCIYAAAMrSURB
+ VDjLpZNLaBx1AMZ/M/P/78zOzO7ObDbvNUnTxsUUm6YmaulNxN70UKEIRTyIBy8KHrypRUTw4E
+ k8CqKnXuyhHgQRFTRNAvVFbOnDNO/EfWZmdmczszPrwcdBvPnBd/ng98F3+OB/Svl3cPbSx5mZ
+ +ZkXjKx+setHs4cHbaW+7d2s79SvhK29j+6vvXH0nwVPfLh1WsTptdnxuDDxoGv3NZWuf4S3G1
+ C722BrrcrOnY1f/ebO05s337n3N6cBLLy1bI7njr4uD4nJhx4by5SGLQYcAzWnI6SGVFUkQKwM
+ RqH/jGHNfXJYXwoBBMDc/MhLThpOJ6ZEMzM4moquQpIVxI5Br5QlHrEImw5xuzRJ0n4beBlABR
+ gwxcXhUp5Ww6OXQvCXo/TPjUJq6FmJldPJOTZ2znj++HOfnwQQ0y9+e67X6iykpmTCNTnY9xBj
+ eTQVelFC0u3RjxNI+6iaQiajYtmGlXa6NxZe/f4pobv24/X9thBSYebUEHc26zT6kLMkaZTQ84
+ +IvYioE9PrRvTTCBSF2PczUTxyVuiOsXHju58Y0XTaQcTJM0OsXt9kaqqIrinEQUTYCPGrAR2v
+ RbcbELS7ZGWEj72hzL+5MqS0uzvBys/CzbsUxx0KJROvnTBZLtCPU/y6j1erE/g1wrBNdqREWK
+ wktdB4QP3h8qO/K6Z2RR8bJmjtUx7KMDtd4MSozuatXX5Zus3tH29Rre7S18GtjFNanAMpr37w
+ 2ti+ABAyeT0eLJ7vtWoDX1z9BiXV0DRJmqakSRfd1iiMOmSPjeKeqVC/H3oPT8r3ZNyzVID3L1
+ V2nDzPqsPlQ2PiGKoJCQFJ4qPIFH0gh3P6ONlHKlQ3ve6EEb57fl7GSh9DAVjaqmrNRsv97Kv1
+ xeurjcthkCyqURs7JzBdE6NokQgJSbQ+O65+euqEszo4UPytWMhvCwBUkSqq1jk356xNDUevLK
+ /sPbl+L7jQ8ZLyUaepGE1xMDZhfDlbKSwPFt1tXcp9qWk1VWjhP2e6dneLvhdqLc/L7B3UzfX1
+ qttsdfKKguo4ZlguO36xWAgLth3mbSsyTatnyFz6B+BnWV0A/UiAAAAAAElFTkSuQmCC
+DTSTART;TZID=Europe/Berlin:20090902T100000
+DTEND;TZID=Europe/Berlin:20090902T110000
+TRANSP:TRANSPARENT
+BEGIN:VALARM
+DESCRIPTION:
+ACTION:DISPLAY
+TRIGGER;VALUE=DURATION:-PT15M
+END:VALARM
+END:VEVENT
+
+END:VCALENDAR
+
diff --git a/tests/testfiles/v2/event/attachmentUtf8.ics.mime b/tests/testfiles/v2/event/attachmentUtf8.ics.mime
new file mode 100644
index 0000000..75df1ed
--- /dev/null
+++ b/tests/testfiles/v2/event/attachmentUtf8.ics.mime
@@ -0,0 +1,107 @@
+Date: Fri, 17 Aug 2012 18:20:48 +0000
+X-Kolab-Type: application/x-vnd.kolab.event
+User-Agent: Libkolab-0.3.1
+Content-Type: multipart/mixed; boundary="nextPart5284273.1bMlkVXeYf"
+Subject: KOrganizer-1687167952.818
+MIME-Version: 1.0
+
+
+--nextPart5284273.1bMlkVXeYf
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: 7Bit
+
+This is a Kolab Groupware object.
+To view this object you will need an email client that can understand the Kolab Groupware format.
+For a list of such email clients please visit
+http://www.kolab.org/get-kolab
+
+--nextPart5284273.1bMlkVXeYf
+Content-Type: application/x-vnd.kolab.event; name="kolab.xml"
+Content-Transfer-Encoding: quoted-printable
+Content-Disposition: attachment; filename="kolab.xml"
+
+<?xml version=3D"1.0" encoding=3D"UTF-8"?>
+<event version=3D"1.0">
+ <product-id>Libkolab-0.3.1, Kolab resource</product-id>
+ <uid>KOrganizer-1687167952.818</uid>
+ <body>=C3=A4=C3=B6=C3=BC%@$=C2=A3=C3=A9=C2=A4=C2=BC=C2=B2=C2=B0=E2=82=AC=
+=C5=A0=EF=BF=BD=D9=80=D8=A3=D8=A8=D9=80</body>
+ <categories>Appointment,Business</categories>
+ <creation-date>2009-09-01T12:52:58Z</creation-date>
+ <last-modification-date>2009-09-01T12:52:58Z</last-modification-date>
+ <sensitivity>private</sensitivity>
+ <start-date>2009-09-02T08:00:00Z</start-date>
+ <summary>=C3=A4=C3=B6=C3=BC%@$=C2=A3=C3=A9=C2=A4=C2=BC=C2=B2=C2=B0=E2=82=
+=AC=C5=A0=EF=BF=BD=D9=80=D8=A3=D8=A8=D9=80</summary>
+ <location>=C3=A4=C3=B6=C3=BC%@$=C2=A3=C3=A9=C2=A4=C2=BC=C2=B2=C2=B0=E2=
+=82=AC=C5=A0=EF=BF=BD=D9=80=D8=A3=D8=A8=D9=80</location>
+ <organizer/>
+ <recurrence cycle=3D"weekly">
+ <interval>1</interval>
+ <day>wednesday</day>
+ <day>friday</day>
+ <range type=3D"number">10</range>
+ <exclusion>2009-09-04</exclusion>
+ </recurrence>
+ <attendee>
+ <display-name>Attendee1</display-name>
+ <smtp-address>a1@example.com</smtp-address>
+ <status>none</status>
+ <request-response>true</request-response>
+ <invitation-sent>false</invitation-sent>
+ <role>required</role>
+ </attendee>
+ <attendee>
+ <display-name>Attendee2</display-name>
+ <smtp-address>a2@example.com</smtp-address>
+ <status>accepted</status>
+ <request-response>true</request-response>
+ <invitation-sent>false</invitation-sent>
+ <role>resource</role>
+ </attendee>
+ <attendee>
+ <display-name>Attendee3</display-name>
+ <smtp-address>a3@example.com</smtp-address>
+ <status>declined</status>
+ <request-response>false</request-response>
+ <invitation-sent>false</invitation-sent>
+ <role>required</role>
+ </attendee>
+ <inline-attachment>=C3=A4=C3=B6=C3=BC%@$=C2=A3=C3=A9=C2=A4=C2=BC=C2=B2=
+=C2=B0=E2=82=AC=C5=A0=EF=BF=BD=D9=80=D8=A3=D8=A8=D9=80</inline-attachme=
+nt>
+ <alarm>15</alarm>
+ <advanced-alarms>
+ <alarm type=3D"display">
+ <enabled>1</enabled>
+ <start-offset>-15</start-offset>
+ </alarm>
+ </advanced-alarms>
+ <show-time-as>free</show-time-as>
+ <end-date>2009-09-02T09:00:00Z</end-date>
+</event>
+
+--nextPart5284273.1bMlkVXeYf
+Content-Type: image/png; name*=utf-8''%C3%A4%C3%B6%C3%BC%25%40$%C2%A3%C3%A9%C2%A4%C2%BC%C2%B2%C2%B0%E2%82%AC%C5%A0%EF%BF%BD%D9%80%D8%A3%D8%A8%D9%80
+Content-Transfer-Encoding: base64
+Content-Disposition: attachment; filename*=''%C3%A4%C3%B6%C3%BC%25%40$%C2%A3%C3%A9%C2%A4%C2%BC%C2%B2%C2%B0%E2%82%AC%C5%A0%EF%BF%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