Page MenuHomePhorge

D5084.1775348960.diff
No OneTemporary

Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None

D5084.1775348960.diff

diff --git a/lib/kolab_sync_data_email.php b/lib/kolab_sync_data_email.php
--- a/lib/kolab_sync_data_email.php
+++ b/lib/kolab_sync_data_email.php
@@ -513,6 +513,7 @@
$attachments = array_merge($message->attachments, $message->inline_parts);
if (!empty($attachments)) {
$result['attachments'] = [];
+ $attachment_ids = [];
foreach ($attachments as $attachment) {
$att = [];
@@ -521,28 +522,37 @@
continue;
}
+ // Eliminate possible duplicates in $attachments
+ if (in_array($attachment->mime_id, $attachment_ids)) {
+ continue;
+ }
+
$filename = rcube_charset::clean($attachment->filename);
if (empty($filename) && $attachment->mimetype == 'text/html') {
$filename = 'HTML Part';
}
- $att['displayName'] = $filename;
+ $att['displayName'] = $filename;
$att['fileReference'] = $serverId . '::' . $attachment->mime_id;
- $att['method'] = 1;
+ // Message/rfc822 parts have Method=5, anything else Method=1
+ // FIXME: Method=6 is for OLE objects, but is it inline images or sth else?
+ $att['method'] = strcasecmp($attachment->mimetype, 'message/rfc822') === 0 ? 5 : 1;
$att['estimatedDataSize'] = $attachment->size;
if (!empty($attachment->content_id)) {
$att['contentId'] = rcube_charset::clean($attachment->content_id);
}
+
if (!empty($attachment->content_location)) {
$att['contentLocation'] = rcube_charset::clean($attachment->content_location);
}
- if (in_array($attachment, $message->inline_parts)) {
+ if (strcasecmp($attachment->disposition, 'inline') === 0) {
$att['isInline'] = 1;
}
$result['attachments'][] = new Syncroton_Model_EmailAttachment($att);
+ $attachment_ids[] = $attachment->mime_id;
}
}
diff --git a/tests/Sync/Sync/EmailTest.php b/tests/Sync/Sync/EmailTest.php
--- a/tests/Sync/Sync/EmailTest.php
+++ b/tests/Sync/Sync/EmailTest.php
@@ -155,6 +155,25 @@
$this->assertStringMatchesFormat("{$folderId}::%d", $xpath->query("{$root}/ns:ServerId")->item(0)->nodeValue);
$this->assertSame('sync test with attachment', $xpath->query("{$root}/ns:ApplicationData/Email:Subject")->item(0)->nodeValue);
$this->assertSame(1, $xpath->query("{$root}/ns:ApplicationData/AirSyncBase:Body")->count());
+ $attachments = $xpath->query("{$root}/ns:ApplicationData/AirSyncBase:Attachments/AirSyncBase:Attachment");
+ $this->assertSame(3, $attachments->count());
+ $att = $attachments->item(0);
+ $this->assertSame('message.eml', $xpath->query('AirSyncBase:DisplayName', $att)->item(0)->nodeValue);
+ $this->assertSame('5', $xpath->query('AirSyncBase:Method', $att)->item(0)->nodeValue);
+ $this->assertSame('63', $xpath->query('AirSyncBase:EstimatedDataSize', $att)->item(0)->nodeValue);
+ $this->assertSame(0, $xpath->query('AirSyncBase:IsInline', $att)->count());
+ $att = $attachments->item(1);
+ $this->assertSame('logo1.gif', $xpath->query('AirSyncBase:DisplayName', $att)->item(0)->nodeValue);
+ $this->assertSame('1', $xpath->query('AirSyncBase:Method', $att)->item(0)->nodeValue);
+ $this->assertSame('76', $xpath->query('AirSyncBase:EstimatedDataSize', $att)->item(0)->nodeValue);
+ $this->assertSame(0, $xpath->query('AirSyncBase:IsInline', $att)->count());
+ $att = $attachments->item(2);
+ $this->assertSame('logo2.gif', $xpath->query('AirSyncBase:DisplayName', $att)->item(0)->nodeValue);
+ $this->assertSame('1', $xpath->query('AirSyncBase:Method', $att)->item(0)->nodeValue);
+ $this->assertSame('76', $xpath->query('AirSyncBase:EstimatedDataSize', $att)->item(0)->nodeValue);
+ $this->assertSame('1', $xpath->query('AirSyncBase:IsInline', $att)->item(0)->nodeValue);
+ $this->assertSame('foo4foo1@bar.net', $xpath->query('AirSyncBase:ContentId', $att)->item(0)->nodeValue);
+ $this->assertSame('fiction1/fiction2', $xpath->query('AirSyncBase:ContentLocation', $att)->item(0)->nodeValue);
return $syncKey;
}
diff --git a/tests/SyncTestCase.php b/tests/SyncTestCase.php
--- a/tests/SyncTestCase.php
+++ b/tests/SyncTestCase.php
@@ -294,7 +294,7 @@
// Make sure user is authenticated
$this->getImapStorage();
- if (!empty($sync->user)) {
+ if ($sync->user) {
// required e.g. for DAV client cache use
\rcube::get_instance()->user = $sync->user;
}
diff --git a/tests/src/mail.sync2 b/tests/src/mail.sync2
--- a/tests/src/mail.sync2
+++ b/tests/src/mail.sync2
@@ -12,9 +12,25 @@
ZWVl
--BOUNDARY
+Content-Type: message/rfc822
+Content-Disposition: attachment; filename=message.eml
+
+Subject: Forwarded
+From: kolab@domain.tld
+
+Forwarded message
+--BOUNDARY
+Content-Transfer-Encoding: base64
+Content-Type: image/gif; name=logo1.gif
+Content-Disposition: attachment; filename=logo1.gif; size=2574
+
+/9j/4AAQSkZJRgABAgEASABIAAD/4QqARXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUA
+--BOUNDARY
Content-Transfer-Encoding: base64
-Content-Type: image/jpeg; name=logo.gif
-Content-Disposition: inline; filename=logo.gif; size=2574
+Content-Type: image/gif; name=logo2.gif
+Content-Disposition: inline; filename=logo2.gif; size=2574
+Content-ID: <foo4foo1@bar.net>
+Content-Location: fiction1/fiction2
/9j/4AAQSkZJRgABAgEASABIAAD/4QqARXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUA
--BOUNDARY--

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 5, 12:29 AM (10 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18831713
Default Alt Text
D5084.1775348960.diff (5 KB)

Event Timeline