Skip to content

Commit

Permalink
Merge branch '2024.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlabci committed Jan 29, 2025
2 parents c5fd935 + 0da259f commit 04406f6
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 24 deletions.
44 changes: 30 additions & 14 deletions tests/tine20/Felamimail/Frontend/ActiveSyncTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ public function testGetEntryWithWinmailDat()
$this->markTestSkipped('The (y)tnef command could not be found!');
}

$controller = $this->_getController($this->_getDevice(Syncroton_Model_Device::TYPE_ANDROID_40));
$device = $this->_getDevice(Syncroton_Model_Device::TYPE_ANDROID_40);
$controller = $this->_getController($device);

$message = $this->_createTestMessage('winmail_dat_attachment.eml', 'winmail_dat_attachment.eml');

Expand Down Expand Up @@ -192,6 +193,14 @@ public function testGetEntryWithWinmailDat()
$syncrotonFileReference = $controller->getFileReference($bookmarkAttachment->fileReference);
$this->assertEquals('text/html', $syncrotonFileReference->contentType);
$this->assertEquals($dataSize, strlen(stream_get_contents($syncrotonFileReference->data)));

$syncrotonMail = $controller->toSyncrotonModel($message, array(
'mimeSupport' => Syncroton_Command_Sync::MIMESUPPORT_SEND_MIME
));
$testDoc = $this->_getDocFromSyncrotonMail($syncrotonMail, $device);
$encodedXml = self::encodeXml($testDoc);
// TODO find out how to extract winmail.dat ...
// self::assertStringContainsString('Content-Description: Extracted Content', $encodedXml);
}

/**
Expand Down Expand Up @@ -275,25 +284,32 @@ public function testInvalidBodyChars()
$message = $this->_emailTestClass->messageTestHelper('invalid_body_chars.eml', 'invalidBodyChars');

$syncrotonEmail = $controller->toSyncrotonModel($message, array('mimeSupport' => Syncroton_Command_Sync::MIMESUPPORT_SEND_MIME, 'bodyPreferences' => array(4 => array('type' => 4))));

$syncrotonEmail->subject = "Hallo\x0E";

$imp = new DOMImplementation();
$dtd = $imp->createDocumentType('AirSync', "-//AIRSYNC//DTD AirSync//EN", "http://www.microsoft.com/");
$testDoc = $imp->createDocument('uri:AirSync', 'Sync', $dtd);
$testDoc->documentElement->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:Syncroton', 'uri:Syncroton');
$testDoc->formatOutput = true;
$testDoc->encoding = 'utf-8';

$syncrotonEmail->appendXML($testDoc->documentElement, $device);

$testDoc = $this->_getDocFromSyncrotonMail($syncrotonEmail, $device);

$xml = $testDoc->saveXML();

$this->assertEquals(preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $xml), $xml);

self::encodeXml($testDoc);
}

protected function _getDocFromSyncrotonMail(Syncroton_Model_Email $email,
Syncroton_Model_Device $device): DOMDocument
{
$imp = new DOMImplementation();
$dtd = $imp->createDocumentType('AirSync', "-//AIRSYNC//DTD AirSync//EN",
"http://www.microsoft.com/");
$testDoc = $imp->createDocument('uri:AirSync', 'Sync', $dtd);
$testDoc->documentElement->setAttributeNS('http://www.w3.org/2000/xmlns/',
'xmlns:Syncroton', 'uri:Syncroton');
$testDoc->formatOutput = true;
$testDoc->encoding = 'utf-8';

$email->appendXML($testDoc->documentElement, $device);
return $testDoc;
}

/**
* try to encode XML until we have wbxml tests
*
Expand Down Expand Up @@ -1179,9 +1195,9 @@ public function testSearch()
* return active device
*
* @param string $_deviceType
* @return ActiveSync_Model_Device
* @return Syncroton_Model_Device
*/
protected function _getDevice($_deviceType)
protected function _getDevice($_deviceType): Syncroton_Model_Device
{
if (isset($this->objects['devices'][$_deviceType])) {
return $this->objects['devices'][$_deviceType];
Expand Down
15 changes: 14 additions & 1 deletion tests/tine20/Felamimail/Frontend/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,18 @@ public function testReplyForwardDeletedMessage(): void
$this->_json->saveMessage($forwardMessageData);
}

public function testForwardWinmailDat()
{
$message = $this->_appendMessageforForwarding('winmail_dat_attachment.eml', 'test attached winmail.dat');
$subject = 'fwd: winmail_dat_attachment-' . Tinebase_Record_Abstract::generateUID(10);
$forwardMessageData = $this->_getForwardMessageData($message['id'], ['subject' => $subject]);
$this->_json->saveMessage($forwardMessageData);
$forwardMessage = $this->_searchForMessageBySubject($subject);
$forwardMessageComplete = $this->_json->getMessage($forwardMessage['id']);
self::assertCount(1, $forwardMessageComplete['attachments'],
print_r($forwardMessageComplete, true));
}

/**
* test reply mail with long references header
*
Expand Down Expand Up @@ -2586,14 +2598,15 @@ public function testAttachmentMethodAttachment()
public function testEmptyWinmailAttachment()
{
$messageToSend = $this->_getMessageData('' , __METHOD__);
$tempFile = $this->_getTempFile(dirname(__FILE__) . '/../files/empty_winmail.dat', 'winmail.dat', 'application/ms-tnef');
$tempFile = $this->_getTempFile(dirname(__FILE__) . '/../files/empty_winmail.dat', 'winmail.dat', 'application/ms-tnef');
$messageToSend['attachments'] = array(
array('tempFile' => array('id' => $tempFile->getId(), 'type' => 'application/ms-tnef'))
);
$this->_json->saveMessage($messageToSend);
$message = $this->_searchForMessageBySubject($messageToSend['subject']);
$complete = $this->_json->getMessage($message['id']);
self::assertEquals(0, count($complete['attachments']));
return $message;
}

/**
Expand Down
27 changes: 18 additions & 9 deletions tine20/Felamimail/js/MessageEditDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,18 +390,27 @@ Tine.Felamimail.MessageEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
handleAttachmentsOfExistingMessage: function (message) {
if (!this.isForwardedMessage() && !this.draftOrTemplate) return;

const attachments = [];
const forwardMode = !this.isForwardedMessage() ? '' : Tine[this.app.appName].registry.get('preferences').get('emlForward');
let attachments = [];
let forwardMode = !this.isForwardedMessage()
? ''
: Tine[this.app.appName].registry.get('preferences').get('emlForward');

if (forwardMode === 'message' || this.draftOrTemplate) {
Ext.each(message.get('attachments'), function (attachment) {
attachment = {
name: attachment['filename'],
type: attachment['content-type'],
size: attachment['size'],
id: message.id + '_' + attachment['partId']
};
attachments.push(attachment);
if (attachment['partId'].match(/winmail/)) {
// we found a winmail extration attachment -> forward the original winmail.dat
forwardMode = 'onlyAsAttachment';
attachments = [];
return false;
} else {
attachment = {
name: attachment['filename'],
type: attachment['content-type'],
size: attachment['size'],
id: message.id + '_' + attachment['partId']
};
attachments.push(attachment);
}
}, this);
}

Expand Down

0 comments on commit 04406f6

Please sign in to comment.