dovecot-2.0-pigeonhole: Fixed FIXME: when redirect address is a ...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Mon Aug 30 03:33:35 EEST 2010
details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/bb69691ffac2
changeset: 1396:bb69691ffac2
user: Stephan Bosch <stephan at rename-it.nl>
date: Mon Aug 30 02:33:26 2010 +0200
description:
Fixed FIXME: when redirect address is a variable, it is checked for validity at runtime.
diffstat:
src/lib-sieve-tool/mail-raw.c | 5 -----
src/lib-sieve/cmd-redirect.c | 42 +++++++++++++++++++++++++++++-------------
src/lib-sieve/sieve-address-parts.c | 10 +++++-----
src/managesieve/cmd-putscript.c | 2 +-
4 files changed, 35 insertions(+), 24 deletions(-)
diffs (151 lines):
diff -r 0e80e5a03870 -r bb69691ffac2 src/lib-sieve-tool/mail-raw.c
--- a/src/lib-sieve-tool/mail-raw.c Mon Aug 30 02:18:54 2010 +0200
+++ b/src/lib-sieve-tool/mail-raw.c Mon Aug 30 02:33:26 2010 +0200
@@ -1,11 +1,6 @@
/* Copyright (c) 2002-2010 Pigeonhole authors, see the included COPYING file
*/
-/* FIXME: This file was gratefully stolen from dovecot/src/deliver/deliver.c and
- * altered to suit our needs. So, this contains lots and lots of duplicated
- * code.
- */
-
#include "lib.h"
#include "istream.h"
#include "istream-seekable.h"
diff -r 0e80e5a03870 -r bb69691ffac2 src/lib-sieve/cmd-redirect.c
--- a/src/lib-sieve/cmd-redirect.c Mon Aug 30 02:18:54 2010 +0200
+++ b/src/lib-sieve/cmd-redirect.c Mon Aug 30 02:33:26 2010 +0200
@@ -120,14 +120,14 @@
(validator, cmd, arg, "address", 1, SAAT_STRING) ) {
return FALSE;
}
-
+
if ( !sieve_validator_argument_activate(validator, cmd, arg, FALSE) )
return FALSE;
- /* We can only assess the validity of the outgoing address when it is
- * a string literal. For runtime-generated strings this needs to be
- * done at runtime (FIXME!)
- */
+ /* We can only assess the validity of the outgoing address when it is
+ * a string literal. For runtime-generated strings this needs to be
+ * done at runtime.
+ */
if ( sieve_argument_is_string_literal(arg) ) {
string_t *address = sieve_ast_argument_str(arg);
const char *error;
@@ -136,9 +136,9 @@
T_BEGIN {
/* Verify and normalize the address to 'local_part at domain' */
norm_address = sieve_address_normalize(address, &error);
-
+
if ( norm_address == NULL ) {
- sieve_argument_validate_error(validator, arg,
+ sieve_argument_validate_error(validator, arg,
"specified redirect address '%s' is invalid: %s",
str_sanitize(str_c(address),128), error);
} else {
@@ -148,7 +148,7 @@
} T_END;
return ( norm_address != NULL );
- }
+ }
return TRUE;
}
@@ -193,6 +193,8 @@
struct sieve_side_effects_list *slist = NULL;
struct act_redirect_context *act;
string_t *redirect;
+ bool literal_address;
+ const char *norm_address;
pool_t pool;
int ret;
@@ -205,28 +207,42 @@
return ret;
/* Read the address */
- if ( (ret=sieve_opr_string_read(renv, address, "address", &redirect)) <= 0 )
+ if ( (ret=sieve_opr_string_read_ex(renv, address, "address", &redirect,
+ &literal_address)) <= 0 )
return ret;
/*
* Perform operation
*/
- /* FIXME: perform address normalization if the string is not a string literal
- */
+ if ( !literal_address ) {
+ const char *error;
+
+ /* Verify and normalize the address to 'local_part at domain' */
+ norm_address = sieve_address_normalize(redirect, &error);
+
+ if ( norm_address == NULL ) {
+ sieve_runtime_error(renv, NULL,
+ "specified redirect address '%s' is invalid: %s",
+ str_sanitize(str_c(redirect),128), error);
+ return SIEVE_EXEC_FAILURE;
+ }
+ } else {
+ norm_address = str_c(redirect);
+ }
if ( sieve_runtime_trace_active(renv, SIEVE_TRLVL_ACTIONS) ) {
sieve_runtime_trace(renv, 0, "redirect action");
sieve_runtime_trace_descend(renv);
sieve_runtime_trace(renv, 0, "forward message to address `%s'",
- str_sanitize(str_c(redirect), 80));
+ str_sanitize(norm_address, 80));
}
/* Add redirect action to the result */
pool = sieve_result_pool(renv->result);
act = p_new(pool, struct act_redirect_context, 1);
- act->to_address = p_strdup(pool, str_c(redirect));
+ act->to_address = p_strdup(pool, norm_address);
if ( sieve_result_add_action
(renv, NULL, &act_redirect, slist, (void *) act,
diff -r 0e80e5a03870 -r bb69691ffac2 src/lib-sieve/sieve-address-parts.c
--- a/src/lib-sieve/sieve-address-parts.c Mon Aug 30 02:18:54 2010 +0200
+++ b/src/lib-sieve/sieve-address-parts.c Mon Aug 30 02:33:26 2010 +0200
@@ -183,14 +183,14 @@
(struct sieve_validator *valdtr ATTR_UNUSED, struct sieve_ast_argument **arg,
struct sieve_command *cmd ATTR_UNUSED)
{
- /* FIXME: Currenly trivial, but might need to allow for further validation for
+ /* NOTE: Currenly trivial, but might need to allow for further validation for
* future extensions.
*/
-
- /* Syntax:
+
+ /* Syntax:
* ":localpart" / ":domain" / ":all" (subject to extension)
- */
-
+ */
+
/* Skip tag */
*arg = sieve_ast_argument_next(*arg);
diff -r 0e80e5a03870 -r bb69691ffac2 src/managesieve/cmd-putscript.c
--- a/src/managesieve/cmd-putscript.c Mon Aug 30 02:18:54 2010 +0200
+++ b/src/managesieve/cmd-putscript.c Mon Aug 30 02:33:26 2010 +0200
@@ -283,7 +283,7 @@
ctx->script_size = MANAGESIEVE_ARG_LITERAL_SIZE(args);
nonsync = TRUE;
} else {
- /* FIXME */
+ /* FIXME: allow quoted strings */
client_send_no(client,
"This MANAGESIEVE implementation currently does not allow "
"quoted strings to be used for script contents.");
More information about the dovecot-cvs
mailing list