(guess_level,list_copy): Fixed
(imap_parse): Handle NO case explicitely.
Showing
1 changed file
with
20 additions
and
7 deletions
... | @@ -797,12 +797,17 @@ folder_imap_delete (mu_folder_t folder, const char *name) | ... | @@ -797,12 +797,17 @@ folder_imap_delete (mu_folder_t folder, const char *name) |
797 | void | 797 | void |
798 | guess_level (struct mu_list_response *resp, size_t prefix_len) | 798 | guess_level (struct mu_list_response *resp, size_t prefix_len) |
799 | { | 799 | { |
800 | char *p; | ||
801 | size_t lev = 0; | 800 | size_t lev = 0; |
802 | 801 | ||
803 | for (p = strchr (resp->name + prefix_len, resp->separator); p; | 802 | if (!resp->separator) |
804 | p = strchr (p + 1, resp->separator)) | 803 | lev = 0; |
804 | else | ||
805 | { | ||
806 | char *p = resp->name + prefix_len; | ||
807 | if (p[0] == resp->separator) | ||
808 | for ( ; p; p = strchr (p + 1, resp->separator)) | ||
805 | lev++; | 809 | lev++; |
810 | } | ||
806 | resp->level = lev; | 811 | resp->level = lev; |
807 | } | 812 | } |
808 | 813 | ||
... | @@ -828,11 +833,15 @@ list_copy (mu_list_t dst, mu_list_t src, | ... | @@ -828,11 +833,15 @@ list_copy (mu_list_t dst, mu_list_t src, |
828 | for (mu_iterator_first (itr); !mu_iterator_is_done (itr); | 833 | for (mu_iterator_first (itr); !mu_iterator_is_done (itr); |
829 | mu_iterator_next (itr)) | 834 | mu_iterator_next (itr)) |
830 | { | 835 | { |
836 | char *name; | ||
831 | struct mu_list_response *p; | 837 | struct mu_list_response *p; |
832 | mu_iterator_current (itr, (void **)&p); | 838 | mu_iterator_current (itr, (void **)&p); |
833 | guess_level (p, prefix_len); | 839 | guess_level (p, prefix_len); |
834 | if ((max_level == 0 || p->level < max_level) | 840 | name = p->name + prefix_len; |
835 | && (!namecmp || namecmp (pattern, p->name) == 0)) | 841 | if (name[0] == p->separator && pattern[0] != p->separator) |
842 | name++; | ||
843 | if ((max_level == 0 || p->level <= max_level) | ||
844 | && (!namecmp || namecmp (pattern, name) == 0)) | ||
836 | mu_list_append (dst, p); | 845 | mu_list_append (dst, p); |
837 | else | 846 | else |
838 | free (p); | 847 | free (p); |
... | @@ -2437,7 +2446,7 @@ imap_parse (f_imap_t f_imap) | ... | @@ -2437,7 +2446,7 @@ imap_parse (f_imap_t f_imap) |
2437 | { | 2446 | { |
2438 | /* Cool we are doing ok. */ | 2447 | /* Cool we are doing ok. */ |
2439 | } | 2448 | } |
2440 | else /* NO and BAD */ | 2449 | else if (strcasecmp (response, "NO") == 0) |
2441 | { | 2450 | { |
2442 | if (strncasecmp (remainder, "LOGIN", 5) == 0) | 2451 | if (strncasecmp (remainder, "LOGIN", 5) == 0) |
2443 | { | 2452 | { |
... | @@ -2446,13 +2455,17 @@ imap_parse (f_imap_t f_imap) | ... | @@ -2446,13 +2455,17 @@ imap_parse (f_imap_t f_imap) |
2446 | mu_observable_notify (observable, MU_EVT_AUTHORITY_FAILED); | 2455 | mu_observable_notify (observable, MU_EVT_AUTHORITY_FAILED); |
2447 | status = MU_ERR_AUTH_FAILURE; | 2456 | status = MU_ERR_AUTH_FAILURE; |
2448 | } | 2457 | } |
2458 | else if (strncasecmp (remainder, "LIST", 4) == 0) | ||
2459 | status = MU_ERR_NOENT; | ||
2449 | else | 2460 | else |
2461 | status = MU_ERR_FAILURE; | ||
2462 | } | ||
2463 | else /* NO and BAD */ | ||
2450 | { | 2464 | { |
2451 | status = EINVAL; | 2465 | status = EINVAL; |
2452 | mu_error ("NO/Bad Tagged: %s %s\n", response, remainder); | 2466 | mu_error ("NO/Bad Tagged: %s %s\n", response, remainder); |
2453 | } | 2467 | } |
2454 | } | 2468 | } |
2455 | } | ||
2456 | f_imap->ptr = f_imap->buffer; | 2469 | f_imap->ptr = f_imap->buffer; |
2457 | } | 2470 | } |
2458 | 2471 | ... | ... |
-
Please register or sign in to post a comment