dovecot-2.0-pigeonhole: Fixed FIXME: fileinto folder name utf-8 ...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Mon Aug 30 11:30:58 EEST 2010
details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/a4f1f8b81535
changeset: 1403:a4f1f8b81535
user: Stephan Bosch <stephan at rename-it.nl>
date: Mon Aug 30 10:30:47 2010 +0200
description:
Fixed FIXME: fileinto folder name utf-8 validity is now checked at compiletime or runtime.
diffstat:
src/lib-sieve/ext-fileinto.c | 41 +++++++++++++++++++++++++++++++++--------
src/lib-sieve/sieve-actions.c | 4 +++-
2 files changed, 36 insertions(+), 9 deletions(-)
diffs (95 lines):
diff -r dbe440b85c1b -r a4f1f8b81535 src/lib-sieve/ext-fileinto.c
--- a/src/lib-sieve/ext-fileinto.c Mon Aug 30 10:13:54 2010 +0200
+++ b/src/lib-sieve/ext-fileinto.c Mon Aug 30 10:30:47 2010 +0200
@@ -13,7 +13,7 @@
#include "lib.h"
#include "str-sanitize.h"
-#include "imap-utf7.h"
+#include "unichar.h"
#include "sieve-common.h"
#include "sieve-extensions.h"
@@ -113,7 +113,21 @@
return FALSE;
}
- return sieve_validator_argument_activate(valdtr, cmd, arg, FALSE);
+ if ( !sieve_validator_argument_activate(valdtr, cmd, arg, FALSE) )
+ return FALSE;
+
+ /* Check name validity when folder argument is not a variable */
+ if ( sieve_argument_is_string_literal(arg) ) {
+ const char *folder = sieve_ast_argument_strc(arg);
+
+ if ( !uni_utf8_str_is_valid(folder) ) {
+ sieve_command_validate_error(valdtr, cmd,
+ "folder name specified for fileinto command is not utf-8: %s", folder);
+ return FALSE;
+ }
+ }
+
+ return TRUE;
}
/*
@@ -154,7 +168,8 @@
{
struct sieve_side_effects_list *slist = NULL;
string_t *folder;
- const char *mailbox;
+ bool folder_literal;
+ bool trace = sieve_runtime_trace_active(renv, SIEVE_TRLVL_ACTIONS);
int ret = 0;
/*
@@ -166,20 +181,30 @@
return ret;
/* Folder operand */
- if ( (ret=sieve_opr_string_read(renv, address, "folder", &folder)) <= 0 )
+ if ( (ret=sieve_opr_string_read_ex(renv, address, "folder", &folder,
+ &folder_literal)) <= 0 )
return ret;
/*
* Perform operation
*/
- mailbox = str_sanitize(str_c(folder), 64);
-
- if ( sieve_runtime_trace_active(renv, SIEVE_TRLVL_ACTIONS) ) {
+ if ( trace ) {
sieve_runtime_trace(renv, 0, "fileinto action");
sieve_runtime_trace_descend(renv);
+ }
+
+ if ( !folder_literal && !uni_utf8_str_is_valid(str_c(folder)) ) {
+ sieve_runtime_error(renv, NULL,
+ "folder name specified for fileinto command is not utf-8: %s",
+ str_c(folder));
+ return SIEVE_EXEC_FAILURE;
+ }
+
+
+ if ( trace ) {
sieve_runtime_trace(renv, 0, "store message in mailbox `%s'",
- str_sanitize(mailbox, 80));
+ str_sanitize(str_c(folder), 80));
}
/* Add action to result */
diff -r dbe440b85c1b -r a4f1f8b81535 src/lib-sieve/sieve-actions.c
--- a/src/lib-sieve/sieve-actions.c Mon Aug 30 10:13:54 2010 +0200
+++ b/src/lib-sieve/sieve-actions.c Mon Aug 30 10:30:47 2010 +0200
@@ -352,7 +352,9 @@
*box_r = NULL;
if ( !uni_utf8_str_is_valid(mailbox) ) {
- /* FIXME: check utf-8 validity at compiletime/runtime */
+ /* Just a precaution; already (supposed to be) checked at
+ * compiletime/runtime.
+ */
*error_r = t_strdup_printf("mailbox name not utf-8: %s", mailbox);
*error_code_r = MAIL_ERROR_PARAMS;
return FALSE;
More information about the dovecot-cvs
mailing list