]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
scrub mail content a bit more
authorEvan Prodromou <evan@prodromou.name>
Mon, 21 Jul 2008 04:37:34 +0000 (00:37 -0400)
committerEvan Prodromou <evan@prodromou.name>
Mon, 21 Jul 2008 04:37:34 +0000 (00:37 -0400)
darcs-hash:20080721043734-84dde-de49b283d468334abd4ee4375042b7f2d003823c.gz

maildaemon.php

index d55ecde75f20cf752a5ac8671c5db8af7b22497f..49c66b99b930b875c35a38885644723c126fbc0a 100755 (executable)
@@ -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;
        }
 }