dovecot-2.0-pigeonhole: Fixed FIXME: Imap4flags extension now ch...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Mon Aug 30 03:52:56 EEST 2010


details:   http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/6a7edb7c3f0d
changeset: 1398:6a7edb7c3f0d
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Mon Aug 30 02:52:49 2010 +0200
description:
Fixed FIXME: Imap4flags extension now checks flag keyword syntax before the message is stored.

diffstat:

 src/lib-sieve/plugins/imap4flags/ext-imap4flags-common.c |  42 ++++++++++++++-------
 1 files changed, 28 insertions(+), 14 deletions(-)

diffs (66 lines):

diff -r ef3d551586f9 -r 6a7edb7c3f0d src/lib-sieve/plugins/imap4flags/ext-imap4flags-common.c
--- a/src/lib-sieve/plugins/imap4flags/ext-imap4flags-common.c	Mon Aug 30 02:37:07 2010 +0200
+++ b/src/lib-sieve/plugins/imap4flags/ext-imap4flags-common.c	Mon Aug 30 02:52:49 2010 +0200
@@ -265,34 +265,48 @@
  */
 
 static bool flag_is_valid(const char *flag)
-{	
+{
 	if (*flag == '\\') {
 		/* System flag */
-		const char *atom = t_str_ucase(flag); 
-        
+		const char *atom = t_str_ucase(flag);
+
 		if (
 			(strcmp(atom, "\\ANSWERED") != 0) &&
 			(strcmp(atom, "\\FLAGGED") != 0) &&
 			(strcmp(atom, "\\DELETED") != 0) &&
 			(strcmp(atom, "\\SEEN") != 0) &&
-			(strcmp(atom, "\\DRAFT") != 0) )  
-		{           
+			(strcmp(atom, "\\DRAFT") != 0) )
+		{
 			return FALSE;
 		}
 	} else {
+		const char *p;
+
 		/* Custom keyword:
 		 *
-		 * The validity of the keyword cannot be validated until the 
-		 * target mailbox for the message is known. Meaning that the 
-		 * verfication of keyword can only be performed when the
-		 * action side effect is about to be executed.
-		 *
-		 * FIXME: technically this is nonsense, since we can simply parse
-		 * using the flag-keyword grammar provided by imap.
-		 */					
+		 * Syntax (IMAP4rev1, RFC 3501, Section 9. Formal Syntax) :
+		 *  flag-keyword    = atom
+		 *  atom            = 1*ATOM-CHAR
+		 *  ATOM-CHAR       = <any CHAR except atom-specials>
+		 *  atom-specials   = "(" / ")" / "{" / SP / CTL / list-wildcards /
+		 *                    quoted-specials / resp-specials
+		 *  CTL             =  %x00-1F / %x7F
+		 *  list-wildcards  = "%" / "*"
+		 *  quoted-specials = DQUOTE / "\"
+		 *  resp-specials   = "]"
+		 */
+
+		p = flag;
+		while ( *p != '\0' ) {
+			if ( *p == '(' || *p == ')' || *p == '{' || *p == ' ' ||
+				*p <= 0x1F || *p == 0x7F || *p == '%' || *p ==  '*' ||
+				*p == '"' || *p == '\\' || *p == ']' )
+				return FALSE;
+			p++;
+		}
 	}
 
-	return TRUE;  
+	return TRUE;
 }
 
 /* Flag iterator */


More information about the dovecot-cvs mailing list