Page MenuHomePhabricator

D7732.diff
No OneTemporary

D7732.diff

Index: src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php
===================================================================
--- src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php
+++ 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(
Index: src/applications/metamta/parser/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php
===================================================================
--- src/applications/metamta/parser/__tests__/PhabricatorMetaMTAEmailBodyParserTestCase.php
+++ 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/plain
Expires
Fri, Nov 8, 6:23 AM (4 d, 16 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6715256
Default Alt Text
D7732.diff (2 KB)

Event Timeline