diff options
author | Evan Prodromou <evan@prodromou.name> | 2008-07-21 00:37:34 -0400 |
---|---|---|
committer | Evan Prodromou <evan@prodromou.name> | 2008-07-21 00:37:34 -0400 |
commit | 1fbafb8524137ea0ad5d0da060aa6bd7e8e691f2 (patch) | |
tree | 14a4d1a83110c380d20d83ea88455e75e059ae64 /maildaemon.php | |
parent | 184425796be8a39333b210c872e1ab29e5359409 (diff) |
scrub mail content a bit more
darcs-hash:20080721043734-84dde-de49b283d468334abd4ee4375042b7f2d003823c.gz
Diffstat (limited to 'maildaemon.php')
-rwxr-xr-x | maildaemon.php | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/maildaemon.php b/maildaemon.php index d55ecde75..49c66b99b 100755 --- a/maildaemon.php +++ b/maildaemon.php @@ -186,10 +186,30 @@ class MailerDaemon { } function cleanup_msg($msg) { - # XXX: signatures - # XXX: quoting - preg_replace('/\s+/', ' ', $msg); - return $msg; + $lines = explode("\n"); + + $output = ''; + + foreach ($lines as $line) { + // skip quotes + if (preg_match('/^\s*>.*$/', $line)) { + continue; + } + // skip start of quote + if (preg_match('/^\s*On.*wrote:\s*$/', $line)) { + continue; + } + // skip everything after a sig + if (preg_match('/^\s*--+\s*$/', $line) || + preg_match('/^\s*__+\s*$/', $line)) + { + break; + } + $output .= $line; + } + + preg_replace('/\s+/', ' ', $output); + return $output; } } |