Commit 3c3f3c35 authored by Thomas Roessler's avatar Thomas Roessler

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.)
parent a2c83b00
......@@ -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);
}
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment