Page MenuHomePhorge

D5084.1775356465.diff
No OneTemporary

Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None

D5084.1775356465.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,6 +522,10 @@
continue;
}
+ 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';
@@ -528,21 +533,23 @@
$att['displayName'] = $filename;
$att['fileReference'] = $serverId . '::' . $attachment->mime_id;
- $att['method'] = 1;
+ $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,23 @@
$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);
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,23 @@
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
/9j/4AAQSkZJRgABAgEASABIAAD/4QqARXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUA
--BOUNDARY--

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 5, 2:34 AM (20 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18832077
Default Alt Text
D5084.1775356465.diff (5 KB)

Event Timeline