--- maildrop.php	20 Nov 2007 21:11:35 -0000	1.19
+++ maildrop.php	26 Nov 2007 15:29:24 -0000
@@ -270,7 +270,9 @@
                            'days' => $vacation->getVacationDays(),
                            'reason' => $vacation->getVacationReason(),
                            'ignorelist' => $vacation->getVacationIgnorelist(),
-                           'excludes' => $vacation->getVacationExcludes());
+                           'excludes' => $vacation->getVacationExcludes(),
+                           'start' => $vacation->getVacationStart(),
+                           'end' => $vacation->getVacationEnd());
 
         if (!empty($addresses)) {
             $this->addItem(new Maildrop_Comment(_("Vacation"), $disable, true));
@@ -459,6 +461,14 @@
             foreach ($params['action-value']['addresses'] as $address) {
                 $from = $address;
             }
+            $start = strftime($params['action-value']['start']);
+            if ($start === false) {
+                $start = 0;
+            }
+            $end = strftime($params['action-value']['end']);
+            if ($end === false) {
+                $end = 0;
+            }
 
             /**
              * @TODO
@@ -467,7 +477,11 @@
              */
             $exclude = '';
             foreach ($params['action-value']['excludes'] as $address) {
-                $exclude .= $address . ' ';
+                $address = trim($address, " |\x00..\x1F");
+                $exclude .= $address . '|';
+            }
+            if ($exclude != '') {
+                $exclude = trim($exclude, "|");
             }
             $ignorelist = $params['action-value']['ignorelist'];
             if ($ignorelist == 1) {
@@ -482,12 +496,30 @@
                 $reason = $params['action-value']['reason'];
             }
             $this->_action[] = '  cc $DEFAULT';
+            if ($ignorelist == 1) {
+                $this->_action[] = '  if (/^(List-Id:|Prececence:.*(bulk|junk|list)|From:.*(postmaster|administrator))/)';
+                $this->_action[] = '  {';
+                $this->_action[] = '    exit;';
+                $this->_action[] = '  }';
+            }
+            if ($exclude != '') {
+                $this->_action[] = '  if (/^From:[:wbreak:]*(' . $exclude . ')/)';
+                $this->_action[] = '  {';
+                $this->_action[] = '    exit;';
+                $this->_action[] = '  }';
+            }
+            $this->_action[] = '  current_time=time;';
+            $this->_action[] = '  start_time=' . $start . ';';
+            $this->_action[] = '  end_time=' . $end . ';';
+            $this->_action[] = '  if (($current_time < $start_time) || ($current_time > $end_time))';
+            $this->_action[] = '  {';
+            $this->_action[] = '    exit;';
+            $this->_action[] = '  }';
             $this->_action[] = $xfilter;
             $this->_action[] = '  /^To:.*/';
             $this->_action[] = '  getaddr($MATCH) =~ /^.*/;';
             $this->_action[] = '  MATCH=tolower($MATCH)';
             $this->_action[] = '  flock "vacation.lock" {';
-            $this->_action[] = '    current_time=time;';
             $this->_action[] = '    if (gdbmopen("vacation.dat", "C") == 0)';
             $this->_action[] = '    {';
             $this->_action[] = '      if ((prev_time=gdbmfetch($MATCH)) ne "" && $prev_time >= $current_time - 60 * 60 * 24 * ' . $params['action-value']['days'] . ')';