Cyrus wildcard question (fwd)
Ken Murchison
ken at oceana.com
Wed Dec 3 15:32:17 EST 2003
Rob Siemborski wrote:
> I am out today. Can you play with this patch, and figure out if it does
> the right thing, and if so, apply it to both branches?
Applied and credited. This fixes both cases in point and doesn't seem
to break anything else.
> ---------- Forwarded message ----------
> Date: Tue, 02 Dec 2003 13:19:12 +0200
> From: Stamatis Stefanos <stef at noc.uoa.gr>
> To: Rob Siemborski <rjs3 at andrew.cmu.edu>
> Cc: info-cyrus at lists.andrew.cmu.edu, cyrus-devel at lists.andrew.cmu.edu
> Subject: Re: Cyrus wildcard question
>
> Rob Siemborski wrote:
>
>> On Sat, 29 Nov 2003, Ken Murchison wrote:
>>
>>
>>>> (cyrus-imapd-2.1.16)
>>>
>>>
>>> This is clearly wrong. Its appears to do the same thing in v2.2 as
>>> well.
>>
>>
>>
>> Well, its valid IMAP, even if it is nonsensical (that fun with
>> unsolicited
>> responses and all).
>>
>
> Hello all,
>
> It seems that the applied patch, fails to match a folder like user.robbb
> when a pattern like user.%b is used.
> Let me notice that the case insensitive and case sensitive versions of
> glob_test() were not synced (?). A new porposed vesrion of this patch is
> following. (Tested only for cyrus-2.1.16)
>
>
> Stefanos
>
>
> ------------------------------------------------------------------------
>
> diff -Naur cyrus-imapd-2.1.16_uncompiled-0.4/lib/glob.c cyrus-imapd-2.1.16_uncompiled-0.5/lib/glob.c
> --- cyrus-imapd-2.1.16_uncompiled-0.4/lib/glob.c 2003-02-13 22:15:40.000000000 +0200
> +++ cyrus-imapd-2.1.16_uncompiled-0.5/lib/glob.c 2003-12-01 20:37:45.102604000 +0200
> @@ -213,6 +213,9 @@
> const char *ghier, *phier; /* pointers for '%' patterns */
> const char *start; /* start of input string */
> int newglob;
> + int sepfound; /* Set to 1 when a separator is found
> + * after a '%'. Otherwise 0.
> + */
>
> /* check for remaining partial matches */
> if (min && *min < 0) return (-1);
> @@ -255,6 +258,7 @@
>
> /* loop to manage wildcards */
> do {
> + sepfound = 0;
> /* see if we match to the next '%' or '*' wildcard */
> while (*gptr != '*' && *gptr != '%' && ptr != pend
> && (*gptr == *ptr || (!newglob && *gptr == '?'))) {
> @@ -285,7 +289,7 @@
> gptr = ghier;
> break;
> }
> - if (*ptr == g->sep_char && *ptr != *ghier) {
> + if (*ptr == g->sep_char) {
> if (!*ghier && min
> && *min < ptr - start && ptr != pend
> && *ptr == g->sep_char
> @@ -293,8 +297,8 @@
> *min = gstar ? ptr - start + 1 : -1;
> return (ptr - start);
> }
> - gptr = ghier;
> ghier = NULL;
> + sepfound = 1;
> } else {
> phier = ++ptr;
> gptr = ghier + 1;
> @@ -323,12 +327,13 @@
>
> /* continue if at wildcard or we passed an asterisk */
> } while (*gptr == '*' || *gptr == '%' ||
> - ((gstar || ghier) && (*gptr || ptr != pend)));
> + ((gstar || ghier || sepfound) && (*gptr || ptr != pend)));
> } else {
> /* case insensitive version (same as above, but with TOLOWER()) */
>
> /* loop to manage wildcards */
> do {
> + sepfound = 0;
> /* see if we match to the next '%' or '*' wildcard */
> while (*gptr != '*' && *gptr != '%' && ptr != pend
> && ((unsigned char) *gptr == TOLOWER(*ptr) ||
> @@ -369,6 +374,7 @@
> return (ptr - start);
> }
> ghier = NULL;
> + sepfound = 1;
> } else {
> phier = ++ptr;
> gptr = ghier + 1;
> @@ -398,7 +404,7 @@
>
> /* continue if at wildcard or we passed an asterisk */
> } while (*gptr == '*' || *gptr == '%' ||
> - ((gstar || ghier) && (*gptr || ptr != pend)));
> + ((gstar || ghier || sepfound) && (*gptr || ptr != pend)));
> }
>
> if (min) *min = -1;
--
Kenneth Murchison Oceana Matrix Ltd.
Software Engineer 21 Princeton Place
716-662-8973 x26 Orchard Park, NY 14127
--PGP Public Key-- http://www.oceana.com/~ken/ksm.pgp
More information about the Info-cyrus
mailing list