~ubuntu-branches/ubuntu/quantal/dovecot/quantal

« back to all changes in this revision

Viewing changes to sieve/src/testsuite/testsuite-arguments.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-06-29 09:21:32 UTC
  • mfrom: (4.1.14 sid)
  • Revision ID: james.westby@ubuntu.com-20100629092132-q4pr5lfuvmjqou19
Tags: 1:1.2.12-1ubuntu1
* Merge from Debian Unstable, remaining changes:
  + Add mail-stack-delivery as per server-maverick-mail-integration spec:
   - Update debian/rules
   - Convert existing package to a dummy package and add new binary in debian/control
   - Update maintainer scripts.
   - Move previously installed backups and config files to new package name
     space in preinst
   - Add new debian/mail-stack-delivery.prerm to handle downgrades
   - Rename debian/dovecot-postfix.* to debian/mail-stack-delivery.*
  + Use Snakeoil SSL certificates by default.
    - debian/control: Depend on ssl-cert.
    - debian/patches/ssl-cert-snakeoil.dpatch: Change default SSL cert paths to snakeoil.
    - debian/dovecot-common.postinst: Relax grep for SSL_* a bit.
  + Add autopkgtest to debian/tests/*.
  + Add ufw integration:
    - Created debian/dovecot-common.ufw.profile.
    - debian/rules: install profile.
    - debian/control: suggest ufw.
  + debian/{control,rules}: enable PIE hardening.
  + debian/control: Update Vcs-* headers.
  + Add SMTP-AUTH support for Outlook (login auth mechanism) 
  + debian/dovecot-common.dirs: Added usr/share/doc/dovecot-common
  + debian/patches/fix-dovecot-config-parser.patch: Fix ordering of external config 
    files. (LP: #597818)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include <ctype.h>
22
22
 
23
 
/* 
24
 
 * Testsuite string argument 
 
23
/*
 
24
 * Testsuite string argument
25
25
 */
26
26
 
27
27
static bool arg_testsuite_string_validate
28
 
        (struct sieve_validator *validator, struct sieve_ast_argument **arg, 
 
28
        (struct sieve_validator *validator, struct sieve_ast_argument **arg,
29
29
                struct sieve_command *context);
30
30
 
31
 
const struct sieve_argument_def testsuite_string_argument = { 
32
 
        "@testsuite-string", 
33
 
        NULL, 
34
 
        arg_testsuite_string_validate, 
 
31
const struct sieve_argument_def testsuite_string_argument = {
 
32
        "@testsuite-string",
 
33
        NULL,
 
34
        arg_testsuite_string_validate,
35
35
        NULL, NULL,
36
36
        sieve_arg_catenated_string_generate,
37
37
};
38
38
 
39
39
static bool arg_testsuite_string_validate
40
 
(struct sieve_validator *valdtr, struct sieve_ast_argument **arg, 
 
40
(struct sieve_validator *valdtr, struct sieve_ast_argument **arg,
41
41
        struct sieve_command *cmd)
42
42
{
43
 
        enum { ST_NONE, ST_OPEN, ST_SUBSTITUTION, ST_PARAM, ST_CLOSE } state = 
 
43
        enum { ST_NONE, ST_OPEN, ST_SUBSTITUTION, ST_PARAM, ST_CLOSE } state =
44
44
                ST_NONE;
45
45
        pool_t pool = sieve_ast_pool((*arg)->ast);
46
46
        struct sieve_arg_catenated_string *catstr = NULL;
51
51
        bool result = TRUE;
52
52
        string_t *subs_name = t_str_new(256);
53
53
        string_t *subs_param = t_str_new(256);
54
 
        
 
54
 
55
55
        T_BEGIN {
56
56
                /* Initialize substitution structure */
57
 
        
 
57
 
58
58
                p = strval;
59
59
                strstart = p;
60
60
                while ( result && p < strend ) {
76
76
                                if ( *p == '{' ) {
77
77
                                        state = ST_SUBSTITUTION;
78
78
                                        p++;
79
 
                                } else 
 
79
                                } else
80
80
                                        state = ST_NONE;
81
81
                                break;
82
82
 
83
 
                        /* Got '%{' */ 
 
83
                        /* Got '%{' */
84
84
                        case ST_SUBSTITUTION:
85
 
                                state = ST_PARAM;       
 
85
                                state = ST_PARAM;
86
86
 
87
87
                                while ( *p != '}' && *p != ':' ) {
88
88
                                        if ( !i_isalnum(*p) ) {
89
89
                                                state = ST_NONE;
90
90
                                                break;
91
 
                                        }       
 
91
                                        }
92
92
                                        str_append_c(subs_name, *p);
93
93
                                        p++;
94
94
                                }
95
95
                                break;
96
 
                                
 
96
 
97
97
                        /* Got '%{name' */
98
98
                        case ST_PARAM:
99
99
                                if ( *p == ':' ) {
108
108
 
109
109
                        /* Finished parsing param, expecting '}' */
110
110
                        case ST_CLOSE:
111
 
                                if ( *p == '}' ) {                              
 
111
                                if ( *p == '}' ) {
112
112
                                        struct sieve_ast_argument *strarg;
113
 
                                
114
 
                                        /* We now know that the substitution is valid */        
115
 
                                        
 
113
 
 
114
                                        /* We now know that the substitution is valid */
 
115
 
116
116
                                        if ( catstr == NULL ) {
117
117
                                                catstr = sieve_arg_catenated_string_create(*arg);
118
118
                                        }
119
 
                                
120
 
                                        /* Add the substring that is before the substitution to the 
 
119
 
 
120
                                        /* Add the substring that is before the substitution to the
121
121
                                         * variable-string AST.
122
122
                                         */
123
123
                                        if ( substart > strstart ) {
124
124
                                                string_t *newstr = str_new(pool, substart - strstart);
125
 
                                                str_append_n(newstr, strstart, substart - strstart); 
126
 
                                                
 
125
                                                str_append_n(newstr, strstart, substart - strstart);
 
126
 
127
127
                                                strarg = sieve_ast_argument_string_create_raw
128
128
                                                        ((*arg)->ast, newstr, (*arg)->source_line);
129
129
                                                sieve_arg_catenated_string_add_element(catstr, strarg);
130
 
                                        
 
130
 
131
131
                                                /* Give other substitution extensions a chance to do their work */
132
132
                                                if ( !sieve_validator_argument_activate_super
133
133
                                                        (valdtr, cmd, strarg, FALSE) ) {
135
135
                                                        break;
136
136
                                                }
137
137
                                        }
138
 
                                
 
138
 
139
139
                                        strarg = testsuite_substitution_argument_create
140
 
                                                (valdtr, (*arg)->ast, (*arg)->source_line, str_c(subs_name), 
 
140
                                                (valdtr, (*arg)->ast, (*arg)->source_line, str_c(subs_name),
141
141
                                                        str_c(subs_param));
142
 
                                        
 
142
 
143
143
                                        if ( strarg != NULL )
144
144
                                                sieve_arg_catenated_string_add_element(catstr, strarg);
145
145
                                        else {
146
 
                                                sieve_argument_validate_error(valdtr, *arg, 
 
146
                                                sieve_argument_validate_error(valdtr, *arg,
147
147
                                                        "unknown testsuite substitution type '%s'", str_c(subs_name));
148
148
                                        }
149
149
 
150
150
                                        strstart = p + 1;
151
151
                                        substart = strstart;
152
152
 
153
 
                                        p++;    
 
153
                                        p++;
154
154
                                }
155
 
                
156
 
                                /* Finished, reset for the next substitution */ 
 
155
 
 
156
                                /* Finished, reset for the next substitution */
157
157
                                state = ST_NONE;
158
158
                        }
159
159
                }
161
161
 
162
162
        /* Bail out early if substitution is invalid */
163
163
        if ( !result ) return FALSE;
164
 
        
 
164
 
165
165
        /* Check whether any substitutions were found */
166
166
        if ( catstr == NULL ) {
167
167
                /* No substitutions in this string, pass it on to any other substution
169
169
                 */
170
170
                return sieve_validator_argument_activate_super(valdtr, cmd, *arg, TRUE);
171
171
        }
172
 
        
173
 
        /* Add the final substring that comes after the last substitution to the 
 
172
 
 
173
        /* Add the final substring that comes after the last substitution to the
174
174
         * variable-string AST.
175
175
         */
176
176
        if ( strend > strstart ) {
177
177
                struct sieve_ast_argument *strarg;
178
178
                string_t *newstr = str_new(pool, strend - strstart);
179
 
                str_append_n(newstr, strstart, strend - strstart); 
 
179
                str_append_n(newstr, strstart, strend - strstart);
180
180
 
181
181
                strarg = sieve_ast_argument_string_create_raw
182
182
                        ((*arg)->ast, newstr, (*arg)->source_line);
183
183
                sieve_arg_catenated_string_add_element(catstr, strarg);
184
 
                        
185
 
                /* Give other substitution extensions a chance to do their work */      
 
184
 
 
185
                /* Give other substitution extensions a chance to do their work */
186
186
                if ( !sieve_validator_argument_activate_super
187
187
                        (valdtr, cmd, strarg, FALSE) )
188
188
                        return FALSE;
189
 
        }       
190
 
        
 
189
        }
 
190
 
191
191
        return TRUE;
192
192
}