From 188a18a5a6f34f29821e5815ad81c6156d7104e1 Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan@rename-it.nl> Date: Sat, 8 Mar 2008 01:05:38 +0100 Subject: [PATCH] Variables: fixed bug in match value indexing. --- src/lib-sieve/plugins/variables/variables-match.sieve | 7 +++++++ src/lib-sieve/sieve-match-types.c | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lib-sieve/plugins/variables/variables-match.sieve b/src/lib-sieve/plugins/variables/variables-match.sieve index 9920fa64f..1a10a8e5f 100644 --- a/src/lib-sieve/plugins/variables/variables-match.sieve +++ b/src/lib-sieve/plugins/variables/variables-match.sieve @@ -21,3 +21,10 @@ set "match2" "toptoptop"; if string :matches "${match2}" "*top" { fileinto "TEST 3: ${1}"; } + +set "match3" "ik ben een tukker met grote oren en een lelijke broek."; + +# Test 4 +if string :matches "${match3}" "ik ben * met * en *." { + fileinto "TEST 4: Hij is een ${1} met ${2} en ${3}!"; +} diff --git a/src/lib-sieve/sieve-match-types.c b/src/lib-sieve/sieve-match-types.c index 4d23ded4f..753d46277 100644 --- a/src/lib-sieve/sieve-match-types.c +++ b/src/lib-sieve/sieve-match-types.c @@ -725,6 +725,7 @@ static bool mtch_matches_match const struct sieve_comparator *cmp = mctx->comparator; struct sieve_match_values *mvalues; string_t *match = t_str_new(32); + bool match_found = FALSE; const char *vend = (const char *) val + val_size; const char *kend = (const char *) key + key_size; const char *vp = val; /* Value pointer */ @@ -772,7 +773,7 @@ static bool mtch_matches_match } else wildcard = '\0'; - if ( kp > key+1 ) { + if ( match_found ) { debug_printf("MATCH value (previous): %s %d\n", str_c(match), kp-key); sieve_match_values_add(mvalues, match); } @@ -781,6 +782,9 @@ static bool mtch_matches_match /* Find this section (starting at kp and ending at wp-1)*/ if ( wp > kp ) { + if ( kp > key ) + match_found = TRUE; + while ( (vp < vend) && (kp < wp) ) { #ifdef MATCH_DEBUG const char *skp = kp; -- GitLab