Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14040226
D7732.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D7732.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 12, 8:06 AM (1 d, 19 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6715256
Default Alt Text
D7732.diff (2 KB)
Attached To
Mode
D7732: Fix over-matching of quoted text for message bodies beginning with "On..."
Attached
Detach File
Event Timeline
Log In to Comment