Key being overwritten by reuse of var in filters plugin.
[squirrelmail.git] / plugins / filters / filters.php
index b41302fa60a1bec498143aff96c119006f748933..638d3ccff7c0d296bbf5c7daab0455ce22bc0416 100644 (file)
@@ -192,6 +192,26 @@ function start_filters() {
     sqgetGlobalVar('username', $username, SQ_SESSION);
     sqgetGlobalVar('key',      $key,      SQ_COOKIE);
 
+    $filters = load_filters();
+
+    // No point running spam filters if there aren't any to run //
+    if ($AllowSpamFilters) {
+        $spamfilters = load_spam_filters();
+
+        $AllowSpamFilters = false;
+        foreach($spamfilters as $filterskey=>$value) {
+            if ($value['enabled'] == 'yes') {
+                $AllowSpamFilters = true;
+                break;
+            }
+        }
+    }
+
+    if (!$AllowSpamFilters && empty($filters)) {
+        return;
+    }
+
+
     // Detect if we have already connected to IMAP or not.
     // Also check if we are forced to use a separate IMAP connection
     if ((!isset($imap_stream) && !isset($imapConnection)) ||
@@ -315,7 +335,7 @@ function filter_search_and_delete($imap_stream, $where, $what, $where_to, $user_
         $search_str .= ' ' . $where . ' ' . $what;
     } else {
         $search_str .= ' ' . $where . ' {' . strlen($what) . "}\r\n"
-                    . $what . "\r\n";
+                    . $what;
     }
 
     /* read data back from IMAP */
@@ -883,4 +903,4 @@ function do_error($string) {
     echo "</font></p>\n";
 }
 
-?>
\ No newline at end of file
+?>