Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2022-11-11 01:26:49 +0300
committerDaniel Kesselberg <mail@danielkesselberg.de>2022-11-11 01:55:23 +0300
commit6f4fe62507a59754c6ed15a9546582a5a1a93201 (patch)
treeef41828fa02de8e9b8436a818597c0f01d6fbcd9 /tests
parent0f0a0394c0500a5985708cbff4e73f6924624eea (diff)
Fix broken encoding for outgoing messages
DOMDocument.loadHTML uses ISO-8859-1 by default. Workaround is to convert from UTF-8 to HTML-ENTITIES and call DOMDocument.saveHTML for the documentElement. Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/Service/MailTransmissionTest.php2
-rw-r--r--tests/Unit/Service/MimeMessageTest.php43
-rw-r--r--tests/data/mime-html-greek.txt11
3 files changed, 55 insertions, 1 deletions
diff --git a/tests/Unit/Service/MailTransmissionTest.php b/tests/Unit/Service/MailTransmissionTest.php
index 5490a1d07..cd7295e50 100644
--- a/tests/Unit/Service/MailTransmissionTest.php
+++ b/tests/Unit/Service/MailTransmissionTest.php
@@ -514,7 +514,7 @@ class MailTransmissionTest extends TestCase {
* the expected result is to have an img element with src="cid:123" and
* another part for the attachment with Content-Type: image/png
*/
- $this->assertStringContainsString('img src="cid:', $rawMessage);
+ $this->assertStringContainsString('img src=3D"cid:', $rawMessage);
$this->assertStringContainsString('Content-Type: image/png', $rawMessage);
$this->assertStringContainsString('Content-Disposition: inline', $rawMessage);
}
diff --git a/tests/Unit/Service/MimeMessageTest.php b/tests/Unit/Service/MimeMessageTest.php
index 10214a1eb..d7d2d6204 100644
--- a/tests/Unit/Service/MimeMessageTest.php
+++ b/tests/Unit/Service/MimeMessageTest.php
@@ -210,6 +210,49 @@ class MimeMessageTest extends TestCase {
$this->assertEquals('attachment', $attachmentPart2->getDisposition());
}
+ public function testMultipartAlternativeGreek() {
+ $messageData = new NewMessageData(
+ $this->account,
+ new AddressList(),
+ new AddressList(),
+ new AddressList(),
+ 'Text and HTML message',
+ file_get_contents(__DIR__ . '/../../../tests/data/mime-html-greek.txt'),
+ [],
+ true,
+ false
+ );
+
+ $part = $this->mimeMessage->build(
+ $messageData->isHtml(),
+ $messageData->getBody(),
+ [],
+ );
+
+ $this->assertEquals('multipart/alternative', $part->getType());
+
+ /** @var Horde_Mime_Part[] $subParts */
+ $subParts = $part->getParts();
+ $this->assertCount(2, $subParts);
+
+ $this->assertEquals('text/plain', $subParts[0]->getType());
+ $this->assertEquals('text/html', $subParts[1]->getType());
+
+ $this->assertStringContainsString(
+ "Όλοι οι άνθρωποι γεννιούνται ελεύθεροι
+και ίσοι στην αξιοπρέπεια και τα
+δικαιώματα. Είναι προικισμένοι με λογική
+και συνείδηση, και οφείλουν να
+συμπεριφέρονται μεταξύ τους με πνεύμα
+αδελφοσύνης.",
+ $subParts[0]->getContents(),
+ );
+ $this->assertStringContainsString(
+ 'Όλοι οι άνθρωποι γεννιούνται ελεύθεροι και ίσοι στην αξιοπρέπεια και τα δικαιώματα. Είναι προικισμένοι με λογική και συνείδηση, και οφείλουν να συμπεριφέρονται μεταξύ τους με πνεύμα αδελφοσύνης.',
+ $subParts[1]->getContents()
+ );
+ }
+
/**
* OCA\Mail\Model\Message::createAttachmentDetails
*
diff --git a/tests/data/mime-html-greek.txt b/tests/data/mime-html-greek.txt
new file mode 100644
index 000000000..a4287b7bc
--- /dev/null
+++ b/tests/data/mime-html-greek.txt
@@ -0,0 +1,11 @@
+<html>
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+</head>
+<body>
+ <p>Hello,</p>
+ <p>Όλοι οι άνθρωποι γεννιούνται ελεύθεροι και ίσοι στην αξιοπρέπεια και τα δικαιώματα. Είναι προικισμένοι με λογική και συνείδηση, και οφείλουν να συμπεριφέρονται μεταξύ τους με πνεύμα αδελφοσύνης.</p>
+ <p>Greetings!</p>
+ <p>Bob</p>
+</body>
+</html>