bug-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-mailutils] RMAIL/movemail probs - any more ideas


From: Sergey Poznyakoff
Subject: Re: [bug-mailutils] RMAIL/movemail probs - any more ideas
Date: Thu, 23 Sep 2010 14:51:29 +0300

Duke Normandin <address@hidden> ha escrit:

> Large file! Is `movemail' the only app that writes to this file?

Yes, it is.

> I hope that you have more tricks up your sleeve, to get the mail to go
> into ~/RMAIL. ;)

I guess I do :)  To begin, let me explain what actually happens.  When
downloading from remote mailboxes (i.e. pop and imap), rmail uses an
intermediate file named ~/.newmail-<URL>, where <URL> is the URL of
the mailbox used as the first argument.  After downloading messages
into that file, rmail.el starts to move them into the actual RMAIL file.
For example, when downloading from imap://hamlet:address@hidden
the intermediate file will be named ~/.newmail-hamlet:address@hidden
So far so good.  Problems begin when hex escapes are used in the URL.
For mailutils, any mailbox name is a URL and is treated accordingly.  In
particular, hex expansion is always performed on it.  Now, suppose Emacs
invokes the following command:

  movemail imap://hamlet%40helsingore.net:address@hidden \
        /home/hamlet/.newmail-hamlet%40helsingore.net:address@hidden

Mailutils treats both arguments as URLs and consequently replaces %40
with '@' in each of them.  Thus, instead of the file named in second
argument, it writes the received mail to:

        /home/hamlet/address@hidden:address@hidden

Emacs, however, does not know about this change and still supposes that
/home/hamlet/.newmail-hamlet%40helsingore.net:address@hidden
will be created.  Not being able to find this file, it decides no new
messages arrived and acts accordingly.  That's what's happening in your
case.

The obvious way to fix it is to handle absolute file names verbatim.
Find attached a patch that takes this approach.  Please let me know
if it works for you.

As a side note, I'd suggest to remove (rmail-file-name "~/RMAIL") from
your config.  Normally, it should have been written as:

     (rmail-file-name (expand-file-name "~/RMAIL"))

without it ~ would perhaps be taken verbatim, which is not what you
want.  Besides, ~/RMAIL is the default, so it's no use redefining it
to the same value.

Regards,
Sergey

diff --git a/mailbox/url.c b/mailbox/url.c
index 1b833bf..91caf7e 100644
--- a/mailbox/url.c
+++ b/mailbox/url.c
@@ -40,7 +40,7 @@
 #define AC2(a,b) a ## b
 #define AC4(a,b,c,d) a ## b ## c ## d
 
-static int url_parse0 (mu_url_t, char *, size_t *poff);
+static int url_parse0 (mu_url_t, char *, size_t *poff, int *decode);
 
 static int
 parse_query (const char *query,
@@ -286,7 +286,8 @@ mu_url_parse (mu_url_t url)
   struct _mu_url u;
   size_t pstart;
   mu_secret_t newsec;
-
+  int want_decode;
+  
   if (!url || !url->name)
     return EINVAL;
 
@@ -301,7 +302,7 @@ mu_url_parse (mu_url_t url)
   if (!n)
     return ENOMEM;
 
-  err = url_parse0 (&u, n, &pstart);
+  err = url_parse0 (&u, n, &pstart, &want_decode);
 
   if (!err)
     {
@@ -331,17 +332,18 @@ mu_url_parse (mu_url_t url)
         though.
        */
 
-#define UALLOC(X)                                          \
-  if (u.X && u.X[0] && (url->X = mu_url_decode(u.X)) == 0) \
-    {                                                      \
-       err = ENOMEM;                                       \
-       goto CLEANUP;                                       \
-    }                                                      \
-  else                                                     \
-    {                                                      \
-       /* Set zero-length strings to NULL. */              \
-       u.X = NULL; \
-    }
+#define UALLOC(X)                                                      \
+      if (u.X && u.X[0] &&                                             \
+         !(url->X = (want_decode ? mu_url_decode (u.X) : strdup (u.X)))) \
+       {                                                               \
+         err = ENOMEM;                                                 \
+         goto CLEANUP;                                                 \
+       }                                                               \
+      else                                                             \
+       {                                                               \
+         /* Set zero-length strings to NULL. */                        \
+         u.X = NULL;                                                   \
+       }
 
       UALLOC (scheme);
       UALLOC (user);
@@ -420,7 +422,7 @@ Is this required to be % quoted, though? I hope so!
 */
 
 static int
-url_parse0 (mu_url_t u, char *name, size_t *poff)
+url_parse0 (mu_url_t u, char *name, size_t *poff, int *decode)
 {
   char *start = name;
   char *p;                     /* pointer into name */
@@ -432,11 +434,13 @@ url_parse0 (mu_url_t u, char *name, size_t *poff)
   if (name[0] == '/')
     {
       u->scheme = "file";
+      *decode = 0;
     }
   else if (name[0] == '|')
     {
       int rc;
       u->scheme = "prog";
+      *decode = 1;
       rc = mu_argcv_get (name + 1, NULL, NULL, &u->qargc, &u->qargv);
       if (rc == 0)
        {
@@ -448,6 +452,7 @@ url_parse0 (mu_url_t u, char *name, size_t *poff)
     }
   else
     {
+      *decode = 1;
       /* Parse out the SCHEME. */
       p = strchr (name, ':');
       if (p == NULL)
diff --git a/movemail/movemail.c b/movemail/movemail.c
index afb83e8..4e7bdb9 100644
--- a/movemail/movemail.c
+++ b/movemail/movemail.c
@@ -760,6 +760,14 @@ main (int argc, char **argv)
       return 1;
     }
 
+  if (emacs_mode)
+    {
+      /* Undo the effect of configuration options that may affect
+        interaction with Emacs. */
+      mu_registrar_set_default_record (mu_mbox_record);
+      mu_debug_default_printer = mu_debug_stderr_printer;
+    }
+  
   atexit (close_mailboxes);
   
   source_name = argv[0];

reply via email to

[Prev in Thread] Current Thread [Next in Thread]