From: Thomas Schüttler Date: Fri, 4 Jan 2019 10:43:51 +0000 (+0100) Subject: Add unit test for invalid unicode character X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=8c4991d241ad377c96d71172284b8e433b93fe0f;p=civicrm-core.git Add unit test for invalid unicode character --- diff --git a/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php b/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php index 59a1d0c078..2278bab5f1 100644 --- a/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php +++ b/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php @@ -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 index 0000000000..6ea99f15f1 --- /dev/null +++ b/tests/phpunit/CRM/Utils/Mail/data/bounces/test_invalid_character.eml @@ -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: +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hrt + +--==IFJRGLKFGIR18927894UHRUHIHD