Add unit test for invalid unicode character
authorThomas Schüttler <tschuettler@oxfam.de>
Fri, 4 Jan 2019 10:43:51 +0000 (11:43 +0100)
committerThomas Schüttler <tschuettler@oxfam.de>
Fri, 4 Jan 2019 10:43:51 +0000 (11:43 +0100)
tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php
tests/phpunit/CRM/Utils/Mail/data/bounces/test_invalid_character.eml [new file with mode: 0644]

index 59a1d0c078445cfaa3b0d3d2075fe13255de8065..2278bab5f13339de1ac66ba648628e67c68107ed 100644 (file)
@@ -54,6 +54,19 @@ class CRM_Utils_EmailProcessorTest extends CiviUnitTestCase {
     $this->checkMailingBounces(1);
   }
 
+  /**
+   * Test the job processing function can handle invalid characters.
+   */
+  public function testBounceProcessingInvalidCharacter() {
+    $this->setUpMailing();
+    $mail = 'test_invalid_character.eml';
+
+    copy(__DIR__ . '/data/bounces/' . $mail, __DIR__ . '/data/mail/' .   $mail);
+    $this->callAPISuccess('job', 'fetch_bounces', array());
+    $this->assertFalse(file_exists(__DIR__ . '/data/mail/' . $mail));
+    $this->checkMailingBounces(1);
+  }
+
   /**
    * Tests that a multipart related email does not cause pain & misery & fatal errors.
    *
diff --git a/tests/phpunit/CRM/Utils/Mail/data/bounces/test_invalid_character.eml b/tests/phpunit/CRM/Utils/Mail/data/bounces/test_invalid_character.eml
new file mode 100644 (file)
index 0000000..6ea99f1
--- /dev/null
@@ -0,0 +1,40 @@
+Delivered-To: my@example.com
+Received: by 10.2.13.84 with SMTP id 1234567890;
+        Wed, 19 Dec 2018 10:01:11 +0100 (CET)
+Return-Path: <>
+From: Postmaster@example.com
+To: b.2.1.aaaaaaaaaaaaaaaa@example.com
+Subject: Delivery Status Notification (Failure)
+Message-ID: <abc.def.fhi@example.com>
+Date: Wed, 19 Dec 2018 10:01:07 +0100
+MIME-Version: 1.0
+Content-Type: multipart/report; report-type=delivery-status; boundary="==IFJRGLKFGIR18927894UHRUHIHD"
+
+--==IFJRGLKFGIR18927894UHRUHIHD
+Content-Type: text/plain; charset=ISO-8859-1
+Content-Transfer-Encoding: quoted-printable
+
+Your message
+
+  Subject: test
+
+was not delivered to:
+
+  my@example.com
+
+because:
+
+  Benutzer my (my@example.com) nicht im Domino-Verzeichnis aufgef=FChrt
+
+
+--==IFJRGLKFGIR18927894UHRUHIHD
+Content-Type: message/delivery-status
+
+Reporting-MTA: dns;srv.example.com
+
+Final-Recipient: rfc822;my@example.com
+Action: failed
+Status: 5.0.0
+Diagnostic-Code: X-Notes; Benutzer my (my@example.com) nicht im Domino-Verzeichnis aufgef\81hrt
+
+--==IFJRGLKFGIR18927894UHRUHIHD