diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 2001-09-04 09:30:04 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 2001-09-04 09:30:04 +0000 |
commit | 3c3f3c35b70bbdd89a5be591bc37bde680680c71 (patch) | |
tree | 777d885bf1dc969cf10f5d5aee127fb1181a411f | |
parent | a2c83b0080deb70cbcf44c048cf4c3248df8c451 (diff) |
patch-bac.canonifypath-4.
The attached patch reverts the IMAP canonification patch I reverted
a version ago (sorry for being so wishy-washy). This time I put in
some code to preserve IMAP URL passwords in the initial pass, so
people who like to use those sorts of URLs still can. That was the
only reason I had reverted the patch before.
(From Brendan Cully.)
-rw-r--r-- | imap/util.c | 6 | ||||
-rw-r--r-- | mutt_socket.c | 2 | ||||
-rw-r--r-- | muttlib.c | 7 | ||||
-rw-r--r-- | pop.c | 2 | ||||
-rw-r--r-- | url.c | 14 | ||||
-rw-r--r-- | url.h | 4 |
6 files changed, 24 insertions, 11 deletions
diff --git a/imap/util.c b/imap/util.c index 64d9dfe3..7f88dbac 100644 --- a/imap/util.c +++ b/imap/util.c @@ -58,7 +58,7 @@ int imap_expand_path (char* path, size_t len) mutt_account_tourl (&mx.account, &url); url.path = mx.mbox; - rc = url_ciss_tostring (&url, path, len); + rc = url_ciss_tostring (&url, path, len, U_DECODE_PASSWD); FREE (&mx.mbox); return rc; @@ -223,7 +223,7 @@ void imap_pretty_mailbox (char* path) /* FIXME: That hard-coded constant is bogus. But we need the actual * size of the buffer from mutt_pretty_mailbox. And these pretty * operations usually shrink the result. Still... */ - url_ciss_tostring (&url, path, 1024); + url_ciss_tostring (&url, path, 1024, 0); } FREE (&target.mbox); @@ -426,7 +426,7 @@ void imap_qualify_path (char *dest, size_t len, IMAP_MBOX *mx, char* path) mutt_account_tourl (&mx->account, &url); url.path = path; - url_ciss_tostring (&url, dest, len); + url_ciss_tostring (&url, dest, len, 0); } diff --git a/mutt_socket.c b/mutt_socket.c index 5f43fdc8..eaeeffbf 100644 --- a/mutt_socket.c +++ b/mutt_socket.c @@ -229,7 +229,7 @@ CONNECTION* mutt_conn_find (const CONNECTION* start, const ACCOUNT* account) /* account isn't actually modified, since url isn't either */ mutt_account_tourl ((ACCOUNT*) account, &url); url.path = NULL; - url_ciss_tostring (&url, hook, sizeof (hook)); + url_ciss_tostring (&url, hook, sizeof (hook), 0); mutt_account_hook (hook); conn = start ? start->next : Connections; @@ -461,6 +461,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); } @@ -246,7 +246,7 @@ int pop_open_mailbox (CONTEXT *ctx) mutt_account_tourl (&acct, &url); url.path = NULL; - url_ciss_tostring (&url, buf, sizeof (buf)); + url_ciss_tostring (&url, buf, sizeof (buf), 0); FREE (&ctx->path); ctx->path = safe_strdup (buf); @@ -164,7 +164,7 @@ int url_parse_ciss (ciss_url_t *ciss, char *src) } /* url_ciss_tostring: output the URL string for a given CISS object. */ -int url_ciss_tostring (ciss_url_t* ciss, char* dest, size_t len) +int url_ciss_tostring (ciss_url_t* ciss, char* dest, size_t len, int flags) { if (ciss->scheme == U_UNKNOWN) return -1; @@ -174,10 +174,14 @@ int url_ciss_tostring (ciss_url_t* ciss, char* dest, size_t len) if (ciss->host) { strncat (dest, "//", len - strlen (dest)); - if (ciss->user) - snprintf (dest + strlen (dest), len - strlen (dest), "%s@", - ciss->user); - /* password deliberately omitted. */ + if (ciss->user) { + if (flags & U_DECODE_PASSWD && ciss->pass) + snprintf (dest + strlen (dest), len - strlen (dest), "%s:%s@", + ciss->user, ciss->pass); + else + snprintf (dest + strlen (dest), len - strlen (dest), "%s@", + ciss->user); + } if (ciss->port) snprintf (dest + strlen (dest), len - strlen (dest), "%s:%hu/", @@ -13,6 +13,8 @@ typedef enum url_scheme } url_scheme_t; +#define U_DECODE_PASSWD (1) + typedef struct ciss_url { url_scheme_t scheme; @@ -27,7 +29,7 @@ ciss_url_t; url_scheme_t url_check_scheme (const char *s); int url_parse_file (char *d, const char *src, size_t dl); int url_parse_ciss (ciss_url_t *ciss, char *src); -int url_ciss_tostring (ciss_url_t* ciss, char* dest, size_t len); +int url_ciss_tostring (ciss_url_t* ciss, char* dest, size_t len, int flags); int url_parse_mailto (ENVELOPE *e, char **body, const char *src); #endif |