[#7023] Wrong "Received:" regexp used in vacation date with sieve
Summary Wrong "Received:" regexp used in vacation date with sieve
Queue Ingo
Queue Version 1.2
Type Bug
State Resolved
Priority 2. Medium
Owners Jan Schneider <jan (at) horde (dot) org>
Requester bb (at) apc (dot) ag
Created 07/04/2008 (364 days ago)
Due
Updated 07/04/2008 (364 days ago)
Assigned
Resolved 07/04/2008 (364 days ago)
Attachments
Milestone
Patch No

History
07/04/2008 Jan Schneider Comment #3
Patch ⇒
Assigned to Jan Schneider
State ⇒ Resolved
Reply to this comment
Both is quite common, so I had to go the [0  ] route.
07/04/2008 Jan Schneider Deleted Attachment: sieve-vacation-date.patch
 
07/04/2008 CVS Commit Comment #2 Reply to this comment
07/04/2008 bb (at) apc (dot) ag Comment #1
New Attachment: sieve-vacation-date.patch
Milestone ⇒
Summary ⇒ Wrong "Received:" regexp used in vacation date with sieve
Patch ⇒ 1
Type ⇒ Bug
State ⇒ Unconfirmed
Priority ⇒ 2. Medium
Queue ⇒ Ingo
Reply to this comment
The sieve module of Ingo creates date matching rules if a vacation 
date (start and end) is specified. These rules work correctly from the 
10th to the 31st of each month but not from the 1st until the 9th.

The reason is that the generated regex searches for dates like '04 Jul 
2008'. However, each server I've seen (Postfix, MS Exchange) inserts 
this date as '4 Jul 2008', without a leading zero.

The following diff seems to fix this issue.

# diff --normal lib/Script/sieve.php.ori lib/Script/sieve.php
2753c2753
<         $code = 'if  header :regex "Received" "^.*(' . 
str_pad($begin, 2, '0', STR_PAD_LEFT);
---
         $code = 'if  header :regex "Received" "^.*(' . 
str_pad($begin, 2, ' ', STR_PAD_LEFT);
2755c2755
<             $code .= '|' . str_pad($i, 2, '0', STR_PAD_LEFT);
---
             $code .= '|' . str_pad($i, 2, ' ', STR_PAD_LEFT);
If there are mail servers that use the 04 format, maybe we should use 
"[0 ]$i" instead of the str_pad stuff in the regexp.