bug-mailutils
[Top][All Lists]
Advanced

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

RE: [bug-mailutils] folder names with spaces?


From: Sergey Poznyakoff
Subject: RE: [bug-mailutils] folder names with spaces?
Date: Fri, 31 Mar 2006 11:12:31 EEST

Alain Magloire <address@hidden> wrote:

> Hmm ... Usually Sergey and the other maintainers react quickly with a patch

Aha :) Please try the enclosed patch.

Regards,
Sergey

Index: imap4d/imap4d.h
===================================================================
RCS file: /cvsroot/mailutils/mailutils/imap4d/imap4d.h,v
retrieving revision 1.68
diff -p -u -r1.68 imap4d.h
--- imap4d/imap4d.h     20 Jan 2006 16:29:18 -0000      1.68
+++ imap4d/imap4d.h     31 Mar 2006 08:07:51 -0000
@@ -303,7 +303,8 @@ int util_is_master (void);
 void util_bye (void);  
 void util_atexit (void (*fp) (void));
 void util_chdir (const char *homedir);
-
+int is_atom (const char *s);
+  
 #ifdef WITH_TLS
 int imap4d_init_tls_server (void);
 #endif /* WITH_TLS */
Index: imap4d/list.c
===================================================================
RCS file: /cvsroot/mailutils/mailutils/imap4d/list.c,v
retrieving revision 1.22
diff -p -u -r1.22 list.c
--- imap4d/list.c       4 Dec 2005 21:07:06 -0000       1.22
+++ imap4d/list.c       31 Mar 2006 08:07:52 -0000
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2001, 2002, 2005  Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2002, 2005, 2006  Free Software Foundation, Inc.
 
    GNU Mailutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -313,38 +313,34 @@ list_file (const char *cwd, const char *
   closedir (dirp);
 }
 
-/* Make sure that the file name does not contain any undesirable
-   chars like "{}. If yes send it as a literal string.  */
 static void
-print_file (const char *ref, const char *file, const char *delim)
+print_name (const char *ref, const char *file, const char *delim,
+            const char *attr)
 {
   char *name = mkfullname (ref, file, delim);
-  if (strpbrk (file, "\"{}"))
+  if (strpbrk (name, "\"{}"))
     {
-      util_out (RESP_NONE, "LIST (\\NoInferiors) \"%s\" {%d}", delim,
-               strlen (name));
+      util_out (RESP_NONE, "LIST (%s) \"%s\" {%d}",
+               attr, delim, strlen (name));
       util_send ("%s\r\n", name);
     }
+  else if (is_atom (name))
+    util_out (RESP_NONE, "LIST (%s) \"%s\" %s", attr, delim, name);
   else
-    util_out (RESP_NONE, "LIST (\\NoInferiors) \"%s\" %s", delim, name);
+    util_out (RESP_NONE, "LIST (%s) \"%s\" \"%s\"", attr, delim, name);
   free (name);
 }
 
-/* Make sure that the file name does not contain any undesirable
-   chars like "{}. If yes send it as a literal string.  */
+static void
+print_file (const char *ref, const char *file, const char *delim)
+{
+  print_name (ref, file, delim, "\\NoInferiors");
+}
+
 static void
 print_dir (const char *ref, const char *file, const char *delim)
 {
-  char *name = mkfullname (ref, file, delim);
-  if (strpbrk (file, "\"{}"))
-    {
-      util_out (RESP_NONE, "LIST (\\NoSelect) \"%s\" {%d}", delim,
-               strlen (name));
-      util_send ("%s\r\n", name);
-    }
-  else
-    util_out (RESP_NONE, "LIST (\\NoSelect) \"%s\" %s", delim, name);
-  free (name);
+  print_name (ref, file, delim, "\\NoSelect");
 }
 
 /* Calls the imap_matcher if a match found out the attribute. */
Index: imap4d/util.c
===================================================================
RCS file: /cvsroot/mailutils/mailutils/imap4d/util.c,v
retrieving revision 1.71
diff -p -u -r1.71 util.c
--- imap4d/util.c       20 Jan 2006 11:20:48 -0000      1.71
+++ imap4d/util.c       31 Mar 2006 08:07:54 -0000
@@ -1298,3 +1298,17 @@ util_chdir (const char *homedir)
     mu_error ("Cannot change to home directory `%s': %s",
              homedir, mu_strerror (errno));
 }
+
+int
+is_atom (const char *s)
+{
+  if (strpbrk (s, "(){ \t%*\"\\"))
+    return 0;
+  for (; *s; s++)
+    {
+      if (*(const unsigned char *)s > 127 || iscntrl (*s))
+       return 0;
+    }
+  return 1;
+}
+     
Index: libproto/imap/folder.c
===================================================================
RCS file: /cvsroot/mailutils/mailutils/libproto/imap/folder.c,v
retrieving revision 1.1
diff -p -u -r1.1 folder.c
--- libproto/imap/folder.c      7 Mar 2006 14:49:47 -0000       1.1
+++ libproto/imap/folder.c      31 Mar 2006 08:07:59 -0000
@@ -1,6 +1,6 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
    Copyright (C) 1999, 2000, 2001, 2003, 2004, 
-   2005 Free Software Foundation, Inc.
+   2005, 2006 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -830,6 +830,9 @@ list_copy (mu_list_t dst, mu_list_t src,
 {
   mu_iterator_t itr;
 
+  if (!src)
+    return;
+  
   mu_list_get_iterator (src, &itr);
   for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
        mu_iterator_next (itr))
@@ -1325,7 +1328,9 @@ imap_list (f_imap_t f_imap)
   char *buffer;
   struct mu_list_response *lr;
   int status = 0;
-
+  int argc;
+  char **argv;
+  
   buffer = alloca (len);
   memcpy (buffer, f_imap->buffer, len);
   buffer[len] = '\0';
@@ -1347,7 +1352,7 @@ imap_list (f_imap_t f_imap)
   tok = strtok_r (NULL, " ", &sp);
   /* Get the attibutes.  */
   tok = strtok_r (NULL, ")", &sp);
-  if (tok)
+  if (tok) 
     {
       char *s = NULL;
       char *p = tok;
@@ -1365,15 +1370,19 @@ imap_list (f_imap_t f_imap)
          p = NULL;
        }
     }
-  /* Hiearchy delimeter.  */
-  tok = strtok_r (NULL, " ", &sp);
-  if (tok && strlen (tok) > 2 && strcasecmp (tok, "NIL"))
-    lr->separator = tok[1];
-  /* The path.  */
-  tok = strtok_r (NULL, " ", &sp);
-  if (tok)
+
+  status = mu_argcv_get (sp, "", NULL, &argc, &argv);
+  if (status == 0)
     {
-      char *s = strchr (tok, '{');
+      char *s;
+      
+      /* Hiearchy delimeter.  */
+      tok = argv[0];
+      if (tok && tok[1] == 0 && strcasecmp (tok, "NIL"))
+       lr->separator = tok[0];
+      /* The path.  */
+      tok = argv[1];
+      s = strchr (tok, '{');
       if (s)
        {
          size_t n = strtoul (s + 1, NULL, 10);
@@ -1390,11 +1399,11 @@ imap_list (f_imap_t f_imap)
       else if ((status = imap_string (f_imap, &tok)) == 0)
        {
          mu_off_t sz = 0;
-
+         
          mu_stream_size (f_imap->string.stream, &sz);
          lr->name = calloc (sz + 1, 1);
          if (!lr->name)
-           status = ENOMEM;
+               status = ENOMEM;
          else
            mu_stream_read (f_imap->string.stream, lr->name, sz, 0, NULL);
          mu_stream_truncate (f_imap->string.stream, 0);
@@ -1408,6 +1417,8 @@ imap_list (f_imap_t f_imap)
            status = ENOMEM;
        }
     }
+  mu_argcv_free (argc, argv);
+  
   return status;
 }
 




reply via email to

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