dovecot-1.1: imap_match(): "foo/bar/%" pattern matching to "foo/...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Mar 2 06:10:18 EET 2008
details: http://hg.dovecot.org/dovecot-1.1/rev/3765f80f4d29
changeset: 7314:3765f80f4d29
user: Timo Sirainen <tss at iki.fi>
date: Sun Mar 02 06:09:38 2008 +0200
description:
imap_match(): "foo/bar/%" pattern matching to "foo/" should return CHILDREN
instead of NO.
diffstat:
1 file changed, 18 insertions(+), 7 deletions(-)
src/lib-imap/imap-match.c | 25 ++++++++++++++++++-------
diffs (38 lines):
diff -r ff7b11c64321 -r 3765f80f4d29 src/lib-imap/imap-match.c
--- a/src/lib-imap/imap-match.c Sun Mar 02 06:08:18 2008 +0200
+++ b/src/lib-imap/imap-match.c Sun Mar 02 06:09:38 2008 +0200
@@ -185,16 +185,27 @@ match_sub(struct imap_match_context *ctx
const char **pattern_p)
{
enum imap_match_result ret, match;
+ unsigned int i;
const char *data = *data_p, *pattern = *pattern_p;
/* match all non-wildcards */
- while (*pattern != '\0' && *pattern != '*' && *pattern != '%') {
- if (!CMP_CUR_CHR(ctx, data, pattern)) {
- return *data == '\0' && *pattern == ctx->sep ?
- IMAP_MATCH_CHILDREN : IMAP_MATCH_NO;
- }
- data++; pattern++;
- }
+ i = 0;
+ while (pattern[i] != '\0' && pattern[i] != '*' && pattern[i] != '%') {
+ if (!CMP_CUR_CHR(ctx, data+i, pattern+i)) {
+ if (data[i] != '\0')
+ return IMAP_MATCH_NO;
+ if (pattern[i] == ctx->sep)
+ return IMAP_MATCH_CHILDREN;
+ if (i > 0 && pattern[i-1] == ctx->sep) {
+ /* data="foo/" pattern = "foo/bar/%" */
+ return IMAP_MATCH_CHILDREN;
+ }
+ return IMAP_MATCH_NO;
+ }
+ i++;
+ }
+ data += i;
+ pattern += i;
match = IMAP_MATCH_NO;
while (*pattern == '%') {
More information about the dovecot-cvs
mailing list