From a63dc32f8de65b92ddb036c4b04495e56171aa51 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Mon, 7 May 2001 19:21:40 +0000 Subject: [PATCH] IMAP path canonicalization. From Brendan Cully. --- imap/README | 51 ++++++++++++++++++++++++++------------------------- imap/imap.h | 1 + imap/util.c | 25 +++++++++++++++++++++++++ muttlib.c | 11 +++++++++++ 4 files changed, 63 insertions(+), 25 deletions(-) diff --git a/imap/README b/imap/README index 13d56d85..6b73f7e0 100644 --- a/imap/README +++ b/imap/README @@ -1,30 +1,31 @@ -Mutt's IMAP support is still experimental, in that it hasn't been tested on -a wide variety of servers and machines. It may contain memory leaks, dangling -pointers, and other nasty problems. IWFM. YMMV. Caveant emptor lectorque. +IMAP in mutt should be considered beta quality. For the most part it +works well, but it is still not quite as stable or as full-featured +as some of the other drivers. I believe it is now acceptable for +daily use (and that's how I use it now, currently against Cyrus 1.6.24 and +previously against UW-IMAP 4.7 and 2000). -Note in particular that mutt doesn't handle connection timeouts well at all, -and may often crash in their presence. Please keep backups from within your -editor of messages that take a long time to write - the longer you take, -the more likely your connection is to time out, AND the more valuable your -message probably is. +You may still lose some work if you are suddenly disconnected from your +server (but your mailboxes should be fine). Currently accessing the same +IMAP folder with multiple clients is not supported - it may work, but +no guarantees. There are still several non-critical known bugs, see +http://bugs.guug.de/ for the current list. + +You may also be disappointed in mutt's handling of very large IMAP mailboxes. +To build the message index mutt must fetch a subset of headers from every +message in the mailbox, which costs time and network traffic linear to the +number of messages in your mailbox. + +Nevertheless in general mutt is quite a fast and fully-featured IMAP client. +It tries to be polite to IMAP servers as well, opening few connections and +avoiding needless polls of the server, unlike certain other popular IMAP +clients by certain large corporations :) + +Mutt supports almost all official authentication and security protocols for +IMAP, including SSL/TLS, native CRAM-MD5 and GSSAPI routines, and a SASL +plugin which can handle just about everything else. Please report bugs to mutt-dev@mutt.org and/or brendan@kublai.com. Version, options, stack-trace and .muttdebug files are a plus. -New features vs. the stable distribution: - -* Tab-completion of IMAP folder names -* Folder browsing -* Go-fast stripes -* Postponed-message support -* Server-side copy -* Fast sync -* Secure login (GSSAPI and CRAM-MD5) -* Attach messages from IMAP folders -* Use an IMAP path as your Maildir (set folder={...}) -* Preserve message keywords -* Preserve deleted messages if you don't choose to expunge them -* Delete mailboxes (from the browser) -* Multiple IMAP usernames -* Read-only folder support (toggling read-only is buggy, though) -* More and better segfaults +Brendan Cully +20010506 diff --git a/imap/imap.h b/imap/imap.h index 3cefa694..ae4ae61d 100644 --- a/imap/imap.h +++ b/imap/imap.h @@ -61,6 +61,7 @@ int imap_fetch_message (MESSAGE* msg, CONTEXT* ctx, int msgno); void imap_logout_all (void); /* util.c */ +int imap_expand_path (char* path, size_t len); int imap_parse_path (const char* path, IMAP_MBOX* mx); void imap_pretty_mailbox (char* path); diff --git a/imap/util.c b/imap/util.c index 184dee89..e76d551f 100644 --- a/imap/util.c +++ b/imap/util.c @@ -37,6 +37,31 @@ /* -- public functions -- */ +/* imap_expand_path: IMAP implementation of mutt_expand_path. Rewrite + * an IMAP path in canonical and absolute form. + * Inputs: a buffer containing an IMAP path, and the number of bytes in + * that buffer. + * Outputs: The buffer is rewritten in place with the canonical IMAP path. + * Returns 0 on success, or -1 if imap_parse_path chokes or url_ciss_tostring + * fails, which it might if there isn't enough room in the buffer. */ +int imap_expand_path (char* path, size_t len) +{ + IMAP_MBOX mx; + ciss_url_t url; + int rc; + + if (imap_parse_path (path, &mx) < 0) + return -1; + + mutt_account_tourl (&mx.account, &url); + url.path = mx.mbox; + + rc = url_ciss_tostring (&url, path, len); + FREE (&mx.mbox); + + return rc; +} + /* imap_parse_path: given an IMAP mailbox name, return host, port * and a path IMAP servers will recognise. * mx.mbox is malloc'd, caller must free it */ diff --git a/muttlib.c b/muttlib.c index d7459a3c..4f89f089 100644 --- a/muttlib.c +++ b/muttlib.c @@ -24,6 +24,10 @@ #include "mx.h" #include "url.h" +#ifdef USE_IMAP +#include "imap.h" +#endif + #ifdef HAVE_PGP #include "pgp.h" #endif @@ -455,6 +459,13 @@ char *_mutt_expand_path (char *s, size_t slen, int rx) } while (recurse); +#ifdef USE_IMAP + /* Rewrite IMAP path in canonical form - aids in string comparisons of + * folders. May possibly fail, in which case s should be the same. */ + if (mx_is_imap (s)) + imap_expand_path (s, slen); +#endif + return (s); } -- 2.40.0