remove support for multi-char imap path delimiters again

the idea that this is even possible was based on an incomplete reading
of the imap spec.

however, the infrastructure for supporting multi-char delimiters as such
is retained, as the Flatten option can be used with them.
This commit is contained in:
Oswald Buddenhagen 2015-05-23 10:47:48 +02:00
parent 9d22641b62
commit 72c2d695ac

View File

@ -64,7 +64,7 @@ typedef struct imap_server_conf {
typedef struct imap_store_conf { typedef struct imap_store_conf {
store_conf_t gen; store_conf_t gen;
imap_server_conf_t *server; imap_server_conf_t *server;
char *delimiter; char delimiter;
char use_namespace; char use_namespace;
} imap_store_conf_t; } imap_store_conf_t;
@ -104,7 +104,7 @@ typedef struct imap_store {
/* trash folder's existence is not confirmed yet */ /* trash folder's existence is not confirmed yet */
enum { TrashUnknown, TrashChecking, TrashKnown } trashnc; enum { TrashUnknown, TrashChecking, TrashKnown } trashnc;
uint got_namespace:1; uint got_namespace:1;
char *delimiter; /* hierarchy delimiter */ char delimiter[2]; /* hierarchy delimiter */
list_t *ns_personal, *ns_other, *ns_shared; /* NAMESPACE info */ list_t *ns_personal, *ns_other, *ns_shared; /* NAMESPACE info */
message_t **msgapp; /* FETCH results */ message_t **msgapp; /* FETCH results */
uint caps; /* CAPABILITY results */ uint caps; /* CAPABILITY results */
@ -1112,23 +1112,18 @@ parse_list_rsp( imap_store_t *ctx, list_t *list, char *cmd )
free_list( list ); free_list( list );
if (!(arg = next_arg( &cmd ))) if (!(arg = next_arg( &cmd )))
goto bad_list; goto bad_list;
if (!ctx->delimiter) if (!ctx->delimiter[0])
ctx->delimiter = nfstrdup( arg ); ctx->delimiter[0] = arg[0];
return parse_list( ctx, cmd, parse_list_rsp_p2 ); return parse_list( ctx, cmd, parse_list_rsp_p2 );
} }
static int static int
is_inbox( imap_store_t *ctx, const char *arg, int argl ) is_inbox( imap_store_t *ctx, const char *arg, int argl )
{ {
int i;
char c;
if (!starts_with( arg, argl, "INBOX", 5 )) if (!starts_with( arg, argl, "INBOX", 5 ))
return 0; return 0;
if (arg[5]) if (arg[5] && arg[5] != ctx->delimiter[0])
for (i = 0; (c = ctx->delimiter[i]); i++) return 0;
if (arg[i + 5] != c)
return 0;
return 1; return 1;
} }
@ -1430,7 +1425,6 @@ imap_cleanup_store( imap_store_t *ctx )
{ {
free_generic_messages( ctx->gen.msgs ); free_generic_messages( ctx->gen.msgs );
free_string_list( ctx->gen.boxes ); free_string_list( ctx->gen.boxes );
free( ctx->delimiter );
} }
static void static void
@ -2104,7 +2098,7 @@ imap_open_store_namespace( imap_store_t *ctx )
ctx->state = SST_HALF; ctx->state = SST_HALF;
ctx->prefix = cfg->gen.path; ctx->prefix = cfg->gen.path;
ctx->delimiter = cfg->delimiter ? nfstrdup( cfg->delimiter ) : 0; ctx->delimiter[0] = cfg->delimiter ? cfg->delimiter : 0;
if (((!ctx->prefix && cfg->use_namespace) || !cfg->delimiter) && CAP(NAMESPACE)) { if (((!ctx->prefix && cfg->use_namespace) || !cfg->delimiter) && CAP(NAMESPACE)) {
/* get NAMESPACE info */ /* get NAMESPACE info */
if (!ctx->got_namespace) if (!ctx->got_namespace)
@ -2141,8 +2135,8 @@ imap_open_store_namespace2( imap_store_t *ctx )
{ {
if (!ctx->prefix && cfg->use_namespace) if (!ctx->prefix && cfg->use_namespace)
ctx->prefix = nsp_1st_ns->val; ctx->prefix = nsp_1st_ns->val;
if (!ctx->delimiter) if (!ctx->delimiter[0])
ctx->delimiter = nfstrdup( nsp_1st_dl->val ); ctx->delimiter[0] = nsp_1st_dl->val[0];
imap_open_store_finalize( ctx ); imap_open_store_finalize( ctx );
} else { } else {
imap_open_store_bail( ctx, FAIL_FINAL ); imap_open_store_bail( ctx, FAIL_FINAL );
@ -2855,9 +2849,14 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep )
store->use_namespace = parse_bool( cfg ); store->use_namespace = parse_bool( cfg );
else if (!strcasecmp( "Path", cfg->cmd )) else if (!strcasecmp( "Path", cfg->cmd ))
store->gen.path = nfstrdup( cfg->val ); store->gen.path = nfstrdup( cfg->val );
else if (!strcasecmp( "PathDelimiter", cfg->cmd )) else if (!strcasecmp( "PathDelimiter", cfg->cmd )) {
store->delimiter = nfstrdup( cfg->val ); if (strlen( cfg->val ) != 1) {
else error( "%s:%d: Path delimiter must be exactly one character long\n", cfg->file, cfg->line );
cfg->err = 1;
continue;
}
store->delimiter = cfg->val[0];
} else
parse_generic_store( &store->gen, cfg ); parse_generic_store( &store->gen, cfg );
continue; continue;
} else { } else {