diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 057ff9eb05..5afb2b104f 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1080,6 +1080,7 @@ phutil_register_library_map(array( 'PhabricatorMailManagementResendWorkflow' => 'applications/metamta/management/PhabricatorMailManagementResendWorkflow.php', 'PhabricatorMailManagementWorkflow' => 'applications/metamta/management/PhabricatorMailManagementWorkflow.php', 'PhabricatorMailReceiver' => 'applications/metamta/receiver/PhabricatorMailReceiver.php', + 'PhabricatorMailReceiverTestCase' => 'applications/metamta/receiver/__tests__/PhabricatorMailReceiverTestCase.php', 'PhabricatorMailReplyHandler' => 'applications/metamta/replyhandler/PhabricatorMailReplyHandler.php', 'PhabricatorMailingListsController' => 'applications/mailinglists/controller/PhabricatorMailingListsController.php', 'PhabricatorMailingListsEditController' => 'applications/mailinglists/controller/PhabricatorMailingListsEditController.php', @@ -1757,8 +1758,8 @@ phutil_register_library_map(array( 'ReleephRequestHeaderListView' => 'applications/releeph/view/request/header/ReleephRequestHeaderListView.php', 'ReleephRequestHeaderView' => 'applications/releeph/view/request/header/ReleephRequestHeaderView.php', 'ReleephRequestIntentsView' => 'applications/releeph/view/request/ReleephRequestIntentsView.php', - 'ReleephRequestQuery' => 'applications/releeph/query/ReleephRequestQuery.php', 'ReleephRequestMailReceiver' => 'applications/releeph/mail/ReleephRequestMailReceiver.php', + 'ReleephRequestQuery' => 'applications/releeph/query/ReleephRequestQuery.php', 'ReleephRequestReplyHandler' => 'applications/releeph/mail/ReleephRequestReplyHandler.php', 'ReleephRequestStatus' => 'applications/releeph/constants/ReleephRequestStatus.php', 'ReleephRequestStatusView' => 'applications/releeph/view/request/ReleephRequestStatusView.php', @@ -2823,6 +2824,7 @@ phutil_register_library_map(array( 'PhabricatorMailImplementationTestAdapter' => 'PhabricatorMailImplementationAdapter', 'PhabricatorMailManagementResendWorkflow' => 'PhabricatorSearchManagementWorkflow', 'PhabricatorMailManagementWorkflow' => 'PhutilArgumentWorkflow', + 'PhabricatorMailReceiverTestCase' => 'PhabricatorTestCase', 'PhabricatorMailingListsController' => 'PhabricatorController', 'PhabricatorMailingListsEditController' => 'PhabricatorMailingListsController', 'PhabricatorMailingListsListController' => 'PhabricatorMailingListsController', @@ -3539,8 +3541,8 @@ phutil_register_library_map(array( 'ReleephRequestHeaderListView' => 'AphrontView', 'ReleephRequestHeaderView' => 'AphrontView', 'ReleephRequestIntentsView' => 'AphrontView', - 'ReleephRequestQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'ReleephRequestMailReceiver' => 'PhabricatorObjectMailReceiver', + 'ReleephRequestQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'ReleephRequestReplyHandler' => 'PhabricatorMailReplyHandler', 'ReleephRequestStatusView' => 'AphrontView', 'ReleephRequestTransaction' => 'PhabricatorApplicationTransaction', diff --git a/src/applications/metamta/receiver/__tests__/PhabricatorMailReceiverTestCase.php b/src/applications/metamta/receiver/__tests__/PhabricatorMailReceiverTestCase.php new file mode 100644 index 0000000000..53a5a5d459 --- /dev/null +++ b/src/applications/metamta/receiver/__tests__/PhabricatorMailReceiverTestCase.php @@ -0,0 +1,42 @@ +overrideEnvConfig('metamta.single-reply-handler-prefix', 'prefix'); + + $base = 'alincoln@example.com'; + + $same = array( + 'alincoln@example.com', + '"Abrahamn Lincoln" ', + 'ALincoln@example.com', + 'prefix+alincoln@example.com', + ); + + foreach ($same as $address) { + $this->assertEqual( + true, + PhabricatorMailReceiver::matchAddresses($base, $address), + "Address {$address}"); + } + + $diff = array( + 'a.lincoln@example.com', + 'aluncoln@example.com', + 'prefixalincoln@example.com', + 'badprefix+alincoln@example.com', + 'bad+prefix+alincoln@example.com', + 'prefix+alincoln+sufffix@example.com', + ); + + foreach ($diff as $address) { + $this->assertEqual( + false, + PhabricatorMailReceiver::matchAddresses($base, $address), + "Address: {$address}"); + } + } + +}