From a7c51ac2d032e29e9599a6f64849c24eb1f7f94d Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 12 Sep 2011 02:44:56 -0400
Subject: [PATCH] - Applied fixes from trunk up to r5202

---
 plugins/managesieve/lib/rcube_sieve.php |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/plugins/managesieve/lib/rcube_sieve.php b/plugins/managesieve/lib/rcube_sieve.php
index 230b44b..7f989e0 100644
--- a/plugins/managesieve/lib/rcube_sieve.php
+++ b/plugins/managesieve/lib/rcube_sieve.php
@@ -349,8 +349,9 @@
         $name = array();
 
         // Squirrelmail (Avelsieve)
-        if ($tokens = preg_split('/(#START_SIEVE_RULE.*END_SIEVE_RULE)\r?\n/', $script, -1, PREG_SPLIT_DELIM_CAPTURE)) {
-            foreach($tokens as $token) {
+        if (preg_match('/(#START_SIEVE_RULE.*END_SIEVE_RULE)\r?\n/', $script)) {
+            $tokens = preg_split('/(#START_SIEVE_RULE.*END_SIEVE_RULE)\r?\n/', $script, -1, PREG_SPLIT_DELIM_CAPTURE);
+            foreach ($tokens as $token) {
                 if (preg_match('/^#START_SIEVE_RULE.*/', $token, $matches)) {
                     $name[$i] = "unnamed rule ".($i+1);
                     $content .= "# rule:[".$name[$i]."]\n";
@@ -366,9 +367,10 @@
             }
         }
         // Horde (INGO)
-        else if ($tokens = preg_split('/(# .+)\r?\n/i', $script, -1, PREG_SPLIT_DELIM_CAPTURE)) {
+        else if (preg_match('/(# .+)\r?\n/', $script)) {
+            $tokens = preg_split('/(# .+)\r?\n/', $script, -1, PREG_SPLIT_DELIM_CAPTURE);
             foreach($tokens as $token) {
-                if (preg_match('/^# (.+)/i', $token, $matches)) {
+                if (preg_match('/^# (.+)/', $token, $matches)) {
                     $name[$i] = $matches[1];
                     $content .= "# rule:[" . $name[$i] . "]\n";
                 }

--
Gitblit v1.9.1