View Issue Details

IDProjectCategoryView StatusLast Update
0001344SOGoWeb Preferencespublic2011-07-05 17:32
Reporterbear-cave Assigned Toludovic  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.3.7a 
Target Version1.3.8Fixed in Version1.3.8 
Summary0001344: Sieve filter 'reject' generates incorrect script on single-line messages
Description

If you create a sieve filter with a 'reject' action, and the message accompanying the reject is a single line, then incorrect sieve is generated. The offending line is of the form:

 reject text: "Single line message";

The Dovecot ManageSieve rejects this - "invalid character after 'text:' in multiline string - and drops the filter file. So all your filters mysteriously don't work.

Additional Information

From a quick reading of RFC5228, it looks to me like generally single line text is simply quoted. Multi-line text starts with 'text:'. So the above should be:

reject "Single line message";

or

reject text:

A message with
more than one line.
.
;

In SOGoSieveConverter.m, asSieveQuotedString() checks the input string for newlines and generates single-line format if none, or multi-line format if any are present. In the latter case it does not add the 'text:' prefix. In the case of 'reject' this is always prepended to the result of asSieveQuotedString(). Hence if the reject message is a single line, 'text:' is present incorrectly.

I assume that there is scope for the reverse problem to occur elsewhere - multi-line text being returned to other commands expecting a single line quoted string.

I think what should happen is that 'text:' should be prepended to multi-line values returned from asSieveQuotedString(). Something like the attached (untested, and I'm Objective C ignorant) patch.

TagsNo tags attached.

Activities

2011-06-22 09:08

 

reject.patch (1,036 bytes)   
--- SoObjects/Mailer/SOGoSieveConverter.m	26be786fa82aeb7561b9b066b973742a0aed7b83
+++ SoObjects/Mailer/SOGoSieveConverter.m	8bfa9d286cb751b8f2ff2f3a7ca4f01d244e1cf9
@@ -87,7 +87,7 @@ static NSDictionary *methodRequirements 
         [newLines addObject: line];
     }
 
-  newText = [NSString stringWithFormat: @"\r\n%@\r\n.\r\n",
+  newText = [NSString stringWithFormat: @"text: \r\n%@\r\n.\r\n",
                       [newLines componentsJoinedByString: @"\n"]];
 
   return newText;
@@ -467,7 +467,7 @@ static NSDictionary *methodRequirements 
                 sieveAction = [NSString stringWithFormat: @"%@ %@",
                                         method, [argument asSieveQuotedString]];
               else if ([method isEqualToString: @"reject"])
-                sieveAction = [NSString stringWithFormat: @"%@ text: %@",
+                sieveAction = [NSString stringWithFormat: @"%@ %@",
                                         method, [argument asSieveQuotedString]];
               else
                 scriptError
reject.patch (1,036 bytes)   

2011-06-26 18:51

 

reject2.patch (1,035 bytes)   
--- SoObjects/Mailer/SOGoSieveConverter.m	26be786fa82aeb7561b9b066b973742a0aed7b83
+++ SoObjects/Mailer/SOGoSieveConverter.m	824e2ee181dea55afa94ee0d5e04da7456740864
@@ -87,7 +87,7 @@ static NSDictionary *methodRequirements 
         [newLines addObject: line];
     }
 
-  newText = [NSString stringWithFormat: @"\r\n%@\r\n.\r\n",
+  newText = [NSString stringWithFormat: @"text:\r\n%@\r\n.\r\n",
                       [newLines componentsJoinedByString: @"\n"]];
 
   return newText;
@@ -467,7 +467,7 @@ static NSDictionary *methodRequirements 
                 sieveAction = [NSString stringWithFormat: @"%@ %@",
                                         method, [argument asSieveQuotedString]];
               else if ([method isEqualToString: @"reject"])
-                sieveAction = [NSString stringWithFormat: @"%@ text: %@",
+                sieveAction = [NSString stringWithFormat: @"%@ %@",
                                         method, [argument asSieveQuotedString]];
               else
                 scriptError
reject2.patch (1,035 bytes)   
bear-cave

bear-cave

2011-06-26 18:55

reporter   ~0002639

I have now tried the attached patch 'reject2' and confirmed that it does fix the problem. Single line and multi-line reject messages generate correct Sieve, and 'redirect', the only other free-text argument Sieve action available from the web still works too. Please consider applying.

(I don't seem to be able to delete an attachment I uploaded. Is this expected?)

ludovic

ludovic

2011-07-05 17:32

administrator   ~0002658

Fixed: http://mtn.inverse.ca/revision/diff/48a1bab369727c086d0425d59fd2cf0ffc63b71c/with/d68444a3c794ab5baa8363ca087ec5caad13ba7b

Thanks for your patch!

Issue History

Date Modified Username Field Change
2011-06-22 09:08 bear-cave New Issue
2011-06-22 09:08 bear-cave File Added: reject.patch
2011-06-26 18:51 bear-cave File Added: reject2.patch
2011-06-26 18:55 bear-cave Note Added: 0002639
2011-06-27 14:12 ludovic Status new => assigned
2011-06-27 14:12 ludovic Assigned To => ludovic
2011-06-27 14:13 ludovic Target Version => 1.3.8
2011-07-05 17:32 ludovic Note Added: 0002658
2011-07-05 17:32 ludovic Status assigned => resolved
2011-07-05 17:32 ludovic Fixed in Version => 1.3.8
2011-07-05 17:32 ludovic Resolution open => fixed