1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 22:40:55 +01:00

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:
epriestley 2011-05-16 15:42:20 -07:00
parent f72c1acc63
commit 8fc79035b6

View file

@ -96,9 +96,17 @@ class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
public function getCleanTextBody() { public function getCleanTextBody() {
$body = idx($this->bodies, 'text'); $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) { public static function loadReceiverObject($receiver_name) {