From 80024f051ef88de4dfaf937a87f93348b8dc4cee Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 20 May 2013 15:52:54 -0700 Subject: [PATCH] Add another pattern to quoted email body stripping Summary: Ref T3217. @hlau has an email client which quotes text with: ________________________________________ From: ... Add a regular expression to correctly detect this as quoted body text. Test Plan: Add unit test; executed unit test. Reviewers: btrahan, chad Reviewed By: chad CC: hlau, aran Maniphest Tasks: T3217 Differential Revision: https://secure.phabricator.com/D5986 --- src/__phutil_library_map__.php | 10 +++------- .../{ => parser}/PhabricatorMetaMTAEmailBodyParser.php | 6 ++++++ .../PhabricatorMetaMTAEmailBodyParserTestCase.php | 8 ++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) rename src/applications/metamta/{ => parser}/PhabricatorMetaMTAEmailBodyParser.php (88%) rename src/applications/metamta/{ => parser}/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php (91%) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 6d85b7bda6..f15475e606 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1118,8 +1118,8 @@ phutil_register_library_map(array( 'PhabricatorMetaMTAConfigOptions' => 'applications/config/option/PhabricatorMetaMTAConfigOptions.php', 'PhabricatorMetaMTAController' => 'applications/metamta/controller/PhabricatorMetaMTAController.php', 'PhabricatorMetaMTADAO' => 'applications/metamta/storage/PhabricatorMetaMTADAO.php', - 'PhabricatorMetaMTAEmailBodyParser' => 'applications/metamta/PhabricatorMetaMTAEmailBodyParser.php', - 'PhabricatorMetaMTAEmailBodyParserTestCase' => 'applications/metamta/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php', + 'PhabricatorMetaMTAEmailBodyParser' => 'applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php', + 'PhabricatorMetaMTAEmailBodyParserTestCase' => 'applications/metamta/parser/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php', 'PhabricatorMetaMTAListController' => 'applications/metamta/controller/PhabricatorMetaMTAListController.php', 'PhabricatorMetaMTAMail' => 'applications/metamta/storage/PhabricatorMetaMTAMail.php', 'PhabricatorMetaMTAMailBody' => 'applications/metamta/view/PhabricatorMetaMTAMailBody.php', @@ -2293,11 +2293,7 @@ phutil_register_library_map(array( 'DivinerFileAtomizer' => 'DivinerAtomizer', 'DivinerGenerateWorkflow' => 'DivinerWorkflow', 'DivinerListController' => 'PhabricatorController', - 'DivinerLiveAtom' => - array( - 0 => 'DivinerDAO', - 1 => 'PhabricatorPolicyInterface', - ), + 'DivinerLiveAtom' => 'DivinerDAO', 'DivinerLiveBook' => array( 0 => 'DivinerDAO', diff --git a/src/applications/metamta/PhabricatorMetaMTAEmailBodyParser.php b/src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php similarity index 88% rename from src/applications/metamta/PhabricatorMetaMTAEmailBodyParser.php rename to src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php index fe7c04afbe..0e35fa9388 100644 --- a/src/applications/metamta/PhabricatorMetaMTAEmailBodyParser.php +++ b/src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php @@ -24,6 +24,12 @@ final class PhabricatorMetaMTAEmailBodyParser { '', $body); + // See example in T3217. + $body = preg_replace( + '/^________________________________________\s+From:.*?/imsU', + '', + $body); + return rtrim($body); } diff --git a/src/applications/metamta/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php b/src/applications/metamta/parser/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php similarity index 91% rename from src/applications/metamta/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php rename to src/applications/metamta/parser/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php index b987c4a6db..ccdebf9d72 100644 --- a/src/applications/metamta/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php +++ b/src/applications/metamta/parser/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php @@ -102,6 +102,14 @@ OKAY Sent from my iPhone EOEMAIL +, +<< +Subject: Core World Tariffs +EOMAIL , ); }