summaryrefslogtreecommitdiff
path: root/net-mail/dovecot/files/pigeonhole-fix-vacation-handle.patch
blob: 744b67e28acd513b60f6c398b4750599a29834a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
--- a/src/lib-sieve/plugins/vacation/cmd-vacation.c	Tue Aug 02 17:50:15 2011 +0200
+++ b/src/lib-sieve/plugins/vacation/cmd-vacation.c	Wed Sep 21 00:55:58 2011 +0200
@@ -231,7 +231,7 @@
 	
 	bool mime;
 	
-	string_t *handle;
+	struct sieve_ast_argument *handle_arg;
 };
 
 /* 
@@ -348,10 +348,10 @@
 		*arg = sieve_ast_argument_next(*arg);
 		
 	} else if ( sieve_argument_is(tag, vacation_handle_tag) ) {
-		ctx_data->handle = sieve_ast_argument_str(*arg);
-		
+		ctx_data->handle_arg = *arg;		
+
 		/* Detach optional argument (emitted as mandatory) */
-		*arg = sieve_ast_arguments_detach(*arg,1);
+		*arg = sieve_ast_arguments_detach(*arg, 1);
 	}
 			
 	return TRUE;
@@ -468,34 +468,48 @@
 		return FALSE;
 		
 	/* Construct handle if not set explicitly */
-	if ( ctx_data->handle == NULL ) {
-		string_t *reason = sieve_ast_argument_str(arg);
-		unsigned int size = str_len(reason);
+	if ( ctx_data->handle_arg == NULL ) {
+		T_BEGIN {
+			string_t *handle;
+			string_t *reason = sieve_ast_argument_str(arg);
+			unsigned int size = str_len(reason);
 		
-		/* Precalculate the size of it all */
-		size += ctx_data->subject == NULL ? 
-			sizeof(_handle_empty_subject) - 1 : str_len(ctx_data->subject);
-		size += ctx_data->from == NULL ? 
-			sizeof(_handle_empty_from) - 1 : str_len(ctx_data->from); 
-		size += ctx_data->mime ? 
-			sizeof(_handle_mime_enabled) - 1 : sizeof(_handle_mime_disabled) - 1; 
+			/* Precalculate the size of it all */
+			size += ctx_data->subject == NULL ? 
+				sizeof(_handle_empty_subject) - 1 : str_len(ctx_data->subject);
+			size += ctx_data->from == NULL ? 
+				sizeof(_handle_empty_from) - 1 : str_len(ctx_data->from); 
+			size += ctx_data->mime ? 
+				sizeof(_handle_mime_enabled) - 1 : sizeof(_handle_mime_disabled) - 1; 
 			
-		/* Construct the string */
-		ctx_data->handle = str_new(sieve_command_pool(cmd), size);
-		str_append_str(ctx_data->handle, reason);
+			/* Construct the string */
+			handle = t_str_new(size);
+			str_append_str(handle, reason);
 		
-		if ( ctx_data->subject != NULL )
-			str_append_str(ctx_data->handle, ctx_data->subject);
-		else
-			str_append(ctx_data->handle, _handle_empty_subject);
+			if ( ctx_data->subject != NULL )
+				str_append_str(handle, ctx_data->subject);
+			else
+				str_append(handle, _handle_empty_subject);
 		
-		if ( ctx_data->from != NULL )
-			str_append_str(ctx_data->handle, ctx_data->from);
-		else
-			str_append(ctx_data->handle, _handle_empty_from);
+			if ( ctx_data->from != NULL )
+				str_append_str(handle, ctx_data->from);
+			else
+				str_append(handle, _handle_empty_from);
 			
-		str_append(ctx_data->handle, 
-			ctx_data->mime ? _handle_mime_enabled : _handle_mime_disabled );
+			str_append(handle, 
+				ctx_data->mime ? _handle_mime_enabled : _handle_mime_disabled );
+		
+			/* Create positional handle argument */
+			ctx_data->handle_arg = sieve_ast_argument_string_create
+				(cmd->ast_node, handle, sieve_ast_node_line(cmd->ast_node));
+		} T_END;
+
+		if ( !sieve_validator_argument_activate
+			(valdtr, cmd, ctx_data->handle_arg, TRUE) )
+			return FALSE;
+	} else {
+		/* Attach explicit handle argument as positional */
+		(void)sieve_ast_argument_attach(cmd->ast_node, ctx_data->handle_arg);
 	}
 	
 	return TRUE;
@@ -507,18 +521,12 @@
  
 static bool cmd_vacation_generate
 (const struct sieve_codegen_env *cgenv, struct sieve_command *cmd) 
-{
-	struct cmd_vacation_context_data *ctx_data = 
-		(struct cmd_vacation_context_data *) cmd->data;
-		 
+{		 
 	sieve_operation_emit(cgenv->sblock, cmd->ext, &vacation_operation);
 
 	/* Generate arguments */
 	if ( !sieve_generate_arguments(cgenv, cmd, NULL) )
 		return FALSE;	
-
-	/* FIXME: this will not allow the handle to be a variable */
-	sieve_opr_string_emit(cgenv->sblock, ctx_data->handle);
 		
 	return TRUE;
 }
@@ -779,13 +787,13 @@
 		(struct act_vacation_context *) action->context;
 	
 	sieve_result_action_printf( rpenv, "send vacation message:");
-	sieve_result_printf(rpenv, "    => seconds   : %d\n", ctx->seconds);
+	sieve_result_printf(rpenv, "    => seconds : %d\n", ctx->seconds);
 	if ( ctx->subject != NULL )
-		sieve_result_printf(rpenv, "    => subject: %s\n", ctx->subject);
+		sieve_result_printf(rpenv, "    => subject : %s\n", ctx->subject);
 	if ( ctx->from != NULL )
-		sieve_result_printf(rpenv, "    => from   : %s\n", ctx->from);
+		sieve_result_printf(rpenv, "    => from    : %s\n", ctx->from);
 	if ( ctx->handle != NULL )
-		sieve_result_printf(rpenv, "    => handle : %s\n", ctx->handle);
+		sieve_result_printf(rpenv, "    => handle  : %s\n", ctx->handle);
 	sieve_result_printf(rpenv, "\nSTART MESSAGE\n%s\nEND MESSAGE\n", ctx->reason);
 }