]>
Commit | Line | Data |
---|---|---|
3d27eadc ER |
1 | diff -rupN ../isync-1.0.4_original/./src/drv_imap.c ./src/drv_imap.c |
2 | --- ../isync-1.0.4_original/./src/drv_imap.c 2007-09-22 01:44:12.000000000 -0700 | |
3 | +++ ./src/drv_imap.c 2009-04-22 15:28:58.000000000 -0700 | |
4 | @@ -1678,7 +1678,7 @@ imap_list( store_t *gctx, string_list_t | |
5 | int ret; | |
6 | ||
7 | imap->boxes = 0; | |
8 | - if ((ret = imap_exec_b( ctx, 0, "LIST \"\" \"%s%%\"", ctx->prefix )) != DRV_OK) | |
9 | + if ((ret = imap_exec_b( ctx, 0, "LIST \"\" \"%s*\"", ctx->prefix )) != DRV_OK) | |
10 | return ret; | |
11 | *retb = imap->boxes; | |
12 | return DRV_OK; | |
13 | diff -rupN ../isync-1.0.4_original/./src/drv_maildir.c ./src/drv_maildir.c | |
14 | --- ../isync-1.0.4_original/./src/drv_maildir.c 2008-02-23 01:02:21.000000000 -0800 | |
15 | +++ ./src/drv_maildir.c 2009-04-22 15:34:05.000000000 -0700 | |
16 | @@ -24,6 +24,7 @@ | |
17 | ||
18 | #include "isync.h" | |
19 | ||
20 | +#include <assert.h> | |
21 | #include <limits.h> | |
22 | #include <stdlib.h> | |
23 | #include <string.h> | |
24 | @@ -46,6 +47,56 @@ | |
25 | #include <db.h> | |
26 | #endif /* USE_DB */ | |
27 | ||
28 | +static void encode_maildir_box(const char* in, char* out, size_t size) | |
29 | +{ | |
30 | + const char* p; | |
31 | + char c; | |
32 | + size_t out_chars; | |
33 | + | |
34 | + for (p = in, out_chars = 0; (c = *p); ++p, ++out, ++out_chars) { | |
35 | + assert(out_chars < size); | |
36 | + if (c == '/') { | |
37 | + assert(out_chars < size - 1); | |
38 | + *(out++) = '~'; | |
39 | + *out = '-'; | |
40 | + ++out_chars; | |
41 | + } | |
42 | + else if (c == '~') { | |
43 | + assert(out_chars < size - 1); | |
44 | + *(out++) = '~'; | |
45 | + *out = '~'; | |
46 | + ++out_chars; | |
47 | + } | |
48 | + else { | |
49 | + *out = c; | |
50 | + } | |
51 | + } | |
52 | + assert(out_chars < size); | |
53 | + *out = 0; | |
54 | +} | |
55 | + | |
56 | +static void decode_maildir_box(const char* in, char* out, size_t size) | |
57 | +{ | |
58 | + const char* p; | |
59 | + char c; | |
60 | + size_t out_chars; | |
61 | + | |
62 | + for (p = in, out_chars = 0; (c = *p); ++p, ++out, ++out_chars) { | |
63 | + assert(out_chars < size); | |
64 | + if (c == '~') { | |
65 | + assert(out_chars < size - 1); | |
66 | + c = *(++p); | |
67 | + *out = (c == '-' ? '/' : '~'); | |
68 | + ++out_chars; | |
69 | + } | |
70 | + else { | |
71 | + *out = c; | |
72 | + } | |
73 | + } | |
74 | + assert(out_chars < size); | |
75 | + *out = 0; | |
76 | +} | |
77 | + | |
78 | typedef struct maildir_store_conf { | |
79 | store_conf_t gen; | |
80 | char *inbox; | |
81 | @@ -164,14 +215,17 @@ maildir_list( store_t *gctx, string_list | |
82 | const char *inbox = ((maildir_store_conf_t *)gctx->conf)->inbox; | |
83 | int bl; | |
84 | struct stat st; | |
85 | - char buf[PATH_MAX]; | |
86 | + char buf[PATH_MAX], box[PATH_MAX]; | |
87 | ||
88 | if (*de->d_name == '.') | |
89 | continue; | |
90 | bl = nfsnprintf( buf, sizeof(buf), "%s%s/cur", gctx->conf->path, de->d_name ); | |
91 | if (stat( buf, &st ) || !S_ISDIR(st.st_mode)) | |
92 | continue; | |
93 | - add_string_list( retb, !memcmp( buf, inbox, bl - 4 ) && !inbox[bl - 4] ? "INBOX" : de->d_name ); | |
94 | + | |
95 | + decode_maildir_box(de->d_name, box, PATH_MAX); | |
96 | + add_string_list( retb, | |
97 | + !memcmp( buf, inbox, bl - 4 ) && !inbox[bl - 4] ? "INBOX" : box ); | |
98 | } | |
99 | closedir (dir); | |
100 | ||
101 | @@ -717,8 +771,11 @@ maildir_prepare( store_t *gctx, int opts | |
102 | #endif /* USE_DB */ | |
103 | if (!strcmp( gctx->name, "INBOX" )) | |
104 | gctx->path = nfstrdup( ((maildir_store_conf_t *)gctx->conf)->inbox ); | |
105 | - else | |
106 | - nfasprintf( &gctx->path, "%s%s", gctx->conf->path, gctx->name ); | |
107 | + else { | |
108 | + char box[_POSIX_PATH_MAX]; | |
109 | + encode_maildir_box(gctx->name, box, _POSIX_PATH_MAX); | |
110 | + nfasprintf( &gctx->path, "%s%s", gctx->conf->path, box ); | |
111 | + } | |
112 | if (opts & OPEN_SETFLAGS) | |
113 | opts |= OPEN_OLD; | |
114 | if (opts & OPEN_EXPUNGE) |