From 5f1b3937e5cb45b033de5edbfa0fc04bb1d545fc Mon Sep 17 00:00:00 2001 From: David Reuss Date: Mon, 19 Dec 2011 08:40:18 -0800 Subject: [PATCH] Added Outlook boundaries for email parser Summary: Outlook wraps a message in 5 dashes on each side when doing replies. This strips english and danish versions. Test Plan: Tried parsing emails with different messages and saw the expected behaviour with patch applied. Ran arc unit, and saw test passed. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: 1239 --- .../parser/PhabricatorMetaMTAEmailBodyParser.php | 12 ++++++++++++ ...PhabricatorMetaMTAEmailBodyParserTestCase.php | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php b/src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php index e101429070..dd07422bcb 100644 --- a/src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php +++ b/src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php @@ -30,6 +30,18 @@ final class PhabricatorMetaMTAEmailBodyParser { '', $body); + // Outlook english + $body = preg_replace( + '/^\s*-----Original Message-----.*?/msU', + '', + $body); + + // Outlook danish + $body = preg_replace( + '/^\s*-----Oprindelig Meddelelse-----.*?/msU', + '', + $body); + return rtrim($body); } diff --git a/src/applications/metamta/parser/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php b/src/applications/metamta/parser/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php index 3b8bbce033..a7f1a87fa3 100644 --- a/src/applications/metamta/parser/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php +++ b/src/applications/metamta/parser/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php @@ -57,6 +57,22 @@ On Fri, May 27, 2011 at 9:39 AM, Someone > ... +EOEMAIL +, +<< ... +EOEMAIL +, +<< ... EOEMAIL ); }