dovecot-2.2-pigeonhole: lib-sieve: variables extension: Fixed ha...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Sun Nov 29 20:47:19 UTC 2015
details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/7e9392cc0ed5
changeset: 2155:7e9392cc0ed5
user: Stephan Bosch <stephan at rename-it.nl>
date: Sun Nov 29 21:47:14 2015 +0100
description:
lib-sieve: variables extension: Fixed handling of empty string by the `:length' set modifier.
An empty string yielded an empty string rather than "0".
diffstat:
src/lib-sieve/plugins/enotify/vmodf-encodeurl.c | 5 ++
src/lib-sieve/plugins/variables/cmd-set.c | 32 +++++++-------
src/lib-sieve/plugins/variables/ext-variables-modifiers.c | 25 +++++++++++
tests/extensions/variables/modifiers.svtest | 10 ++++-
4 files changed, 54 insertions(+), 18 deletions(-)
diffs (143 lines):
diff -r 168b6eb4671e -r 7e9392cc0ed5 src/lib-sieve/plugins/enotify/vmodf-encodeurl.c
--- a/src/lib-sieve/plugins/enotify/vmodf-encodeurl.c Sun Nov 29 21:33:33 2015 +0100
+++ b/src/lib-sieve/plugins/enotify/vmodf-encodeurl.c Sun Nov 29 21:47:14 2015 +0100
@@ -67,6 +67,11 @@
unsigned int i;
const unsigned char *c;
+ if ( str_len(in) == 0 ) {
+ *result = in;
+ return TRUE;
+ }
+
*result = t_str_new(2*str_len(in));
c = str_data(in);
diff -r 168b6eb4671e -r 7e9392cc0ed5 src/lib-sieve/plugins/variables/cmd-set.c
--- a/src/lib-sieve/plugins/variables/cmd-set.c Sun Nov 29 21:33:33 2015 +0100
+++ b/src/lib-sieve/plugins/variables/cmd-set.c Sun Nov 29 21:47:14 2015 +0100
@@ -326,26 +326,24 @@
break;
}
- if ( str_len(value) > 0 ) {
- if ( modf.def != NULL && modf.def->modify != NULL ) {
- if ( !modf.def->modify(value, &new_value) ) {
- value = NULL;
- ret = SIEVE_EXEC_FAILURE;
- break;
- }
+ if ( modf.def != NULL && modf.def->modify != NULL ) {
+ if ( !modf.def->modify(value, &new_value) ) {
+ value = NULL;
+ ret = SIEVE_EXEC_FAILURE;
+ break;
+ }
- sieve_runtime_trace_here
- (renv, SIEVE_TRLVL_COMMANDS, "modify :%s \"%s\" => \"%s\"",
- sieve_variables_modifier_name(&modf), str_c(value), str_c(new_value));
+ sieve_runtime_trace_here
+ (renv, SIEVE_TRLVL_COMMANDS, "modify :%s \"%s\" => \"%s\"",
+ sieve_variables_modifier_name(&modf), str_c(value), str_c(new_value));
- value = new_value;
- if ( value == NULL )
- break;
+ value = new_value;
+ if ( value == NULL )
+ break;
- /* Hold value within limits */
- if ( str_len(value) > EXT_VARIABLES_MAX_VARIABLE_SIZE )
- str_truncate(value, EXT_VARIABLES_MAX_VARIABLE_SIZE);
- }
+ /* Hold value within limits */
+ if ( str_len(value) > EXT_VARIABLES_MAX_VARIABLE_SIZE )
+ str_truncate(value, EXT_VARIABLES_MAX_VARIABLE_SIZE);
}
}
diff -r 168b6eb4671e -r 7e9392cc0ed5 src/lib-sieve/plugins/variables/ext-variables-modifiers.c
--- a/src/lib-sieve/plugins/variables/ext-variables-modifiers.c Sun Nov 29 21:33:33 2015 +0100
+++ b/src/lib-sieve/plugins/variables/ext-variables-modifiers.c Sun Nov 29 21:47:14 2015 +0100
@@ -190,6 +190,11 @@
{
char *content;
+ if ( str_len(in) == 0 ) {
+ *result = in;
+ return TRUE;
+ }
+
*result = t_str_new(str_len(in));
str_append_str(*result, in);
@@ -203,6 +208,11 @@
{
char *content;
+ if ( str_len(in) == 0 ) {
+ *result = in;
+ return TRUE;
+ }
+
*result = t_str_new(str_len(in));
str_append_str(*result, in);
@@ -216,6 +226,11 @@
{
char *content;
+ if ( str_len(in) == 0 ) {
+ *result = in;
+ return TRUE;
+ }
+
*result = t_str_new(str_len(in));
str_append_str(*result, in);
@@ -229,6 +244,11 @@
{
char *content;
+ if ( str_len(in) == 0 ) {
+ *result = in;
+ return TRUE;
+ }
+
*result = t_str_new(str_len(in));
str_append_str(*result, in);
@@ -251,6 +271,11 @@
unsigned int i;
const char *content;
+ if ( str_len(in) == 0 ) {
+ *result = in;
+ return TRUE;
+ }
+
*result = t_str_new(str_len(in) * 2);
content = (const char *) str_data(in);
diff -r 168b6eb4671e -r 7e9392cc0ed5 tests/extensions/variables/modifiers.svtest
--- a/tests/extensions/variables/modifiers.svtest Sun Nov 29 21:33:33 2015 +0100
+++ b/tests/extensions/variables/modifiers.svtest Sun Nov 29 21:47:14 2015 +0100
@@ -70,7 +70,15 @@
}
}
-test "Modifier :length" {
+test "Modifier :length (empty)" {
+ set :length "test" "";
+
+ if not string :is "${test}" "0" {
+ test_fail "modified variable assignment failed";
+ }
+}
+
+test "Modifier :length (simple)" {
set :length "test" "VaLuE";
if not string :is "${test}" "5" {
More information about the dovecot-cvs
mailing list