Page MenuHomePhabricator

D7732.diff

diff --git a/src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php b/src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php
--- a/src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php
+++ b/src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php
@@ -50,10 +50,29 @@
}
private function stripQuotedText($body) {
- $body = preg_replace(
- '/^\s*>?\s*On\b.*\bwrote:.*?/msU',
- '',
- $body);
+
+ // Look for "On <date>, <user> wrote:". This may be split across multiple
+ // lines. We need to be careful not to remove all of a message like this:
+ //
+ // On which day do you want to meet?
+ //
+ // On <date>, <user> wrote:
+ // > Let's set up a meeting.
+
+ $start = null;
+ $lines = phutil_split_lines($body);
+ foreach ($lines as $key => $line) {
+ if (preg_match('/^\s*>?\s*On\b/', $line)) {
+ $start = $key;
+ }
+ if ($start !== null) {
+ if (preg_match('/\bwrote:/', $line)) {
+ $lines = array_slice($lines, 0, $start);
+ $body = implode('', $lines);
+ break;
+ }
+ }
+ }
// Outlook english
$body = preg_replace(
diff --git a/src/applications/metamta/parser/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php b/src/applications/metamta/parser/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php
--- a/src/applications/metamta/parser/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php
+++ b/src/applications/metamta/parser/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php
@@ -31,6 +31,20 @@
}
}
+ public function testFalsePositiveForOnWrote() {
+ $body = <<<EOEMAIL
+On which horse shall you ride?
+
+On Sep 23, alincoln wrote:
+
+> Hey bro do you want to go ride horses tomorrow?
+EOEMAIL;
+
+ $parser = new PhabricatorMetaMTAEmailBodyParser();
+ $stripped = $parser->stripTextBody($body);
+ $this->assertEqual("On which horse shall you ride?", $stripped);
+ }
+
private function getEmailBodiesWithFullCommands() {
$bodies = $this->getEmailBodies();
$with_commands = array();

File Metadata

Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/no/yv/2o2mqmcqruwjtqsr
Default Alt Text
D7732.diff (2 KB)

Event Timeline