Provide an "algorithm" for stripping quoted text from email replies
Summary: There's an undoubtedly-far-more-refined version of this in xmail if someone wants to crib it for me. Otherwise we can anneal this as counterexamples arise. This seems to be what mail.app and gmail do. Test Plan: Used mail receiver console to "send" some mail and verified it was correctly truncated. Reviewed By: jungejason Reviewers: aran, tuomaspelkonen, jungejason CC: aran, jungejason Differential Revision: 290
This commit is contained in:
@@ -96,9 +96,17 @@ class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
|
||||
public function getCleanTextBody() {
|
||||
$body = idx($this->bodies, 'text');
|
||||
|
||||
// TODO: Detect quoted content and exclude it.
|
||||
// TODO: Refine this "algorithm".
|
||||
|
||||
return $body;
|
||||
$lines = explode("\n", trim($body));
|
||||
for ($ii = 0; $ii < count($lines); $ii++) {
|
||||
if (preg_match('/^\s*On\b.*\bwrote:\s*$/', $lines[$ii])) {
|
||||
$lines = array_slice($lines, 0, $ii);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return trim(implode("\n", $lines));
|
||||
}
|
||||
|
||||
public static function loadReceiverObject($receiver_name) {
|
||||
|
||||
Reference in New Issue
Block a user