]> granicus.if.org Git - mutt/commitdiff
patch-bac.canonifypath-4.
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 4 Sep 2001 09:30:04 +0000 (09:30 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 4 Sep 2001 09:30:04 +0000 (09:30 +0000)
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.)

imap/util.c
mutt_socket.c
muttlib.c
pop.c
url.c
url.h

index 64d9dfe37d89371c2d08e59753494e13dd6f4ac1..7f88dbac919d45a3fcbb11a8baf8b2ff68764105 100644 (file)
@@ -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);
 }
 
 
index 5f43fdc81502b936d9557a7760c751a731b85af0..eaeeffbfb30a5e31264b78245966e7fc6a9c8fdf 100644 (file)
@@ -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;
index 532009b107763d3025b83e71fd6efd4af1139eaf..7f06f71a24f28aa794a3884619e7c72e5f52e9cf 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -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);
 }
 
diff --git a/pop.c b/pop.c
index d4e0c73a4669ad24585e83c2e739edbf4254219f..6d7289d824b515eee469229f68ecf48f4a404d53 100644 (file)
--- a/pop.c
+++ b/pop.c
@@ -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);
diff --git a/url.c b/url.c
index 450f588aca190bc450bf6f69cacb04409136a67a..289acb97137dc7a8d8a6d3c8ea26ed18ad890325 100644 (file)
--- a/url.c
+++ b/url.c
@@ -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/",
diff --git a/url.h b/url.h
index 6d00c096aaad5fed364a33fdb2bc70deef996606..0bcc4bdc487f0c2f47d10c63b11804c644ce4ec7 100644 (file)
--- a/url.h
+++ b/url.h
@@ -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