Package: mutt-patched
Version: 1.5.17+20080114-1
Severity: normal
Tags: patch

I have folders from several IMAP servers in my config.  Some of them are
the root (really INBOX) folders, e.g.
  imap://host/
When I try to select one of those, the sidebar cursor jumps to the top,
rather than remaining on that folder.

I tracked this down to a basename() call.  Apparently, basename
sometimes modifies its input...specifically when it ends in a '/'.  I've
attached a patch that makes a copy of the string to send to basename, to
avoid trashing the path members of buffy objects.  I'm wary of
refreshing the sidebar patch, so I just have quilt apply this patch
directly after the sidebar patch.

Thanks,
John

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.22-1-686 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages mutt-patched depends on:
ii  libc6                  2.7-8             GNU C Library: Shared libraries
ii  libgdbm3               1.8.3-3           GNU dbm database routines (runtime
ii  libgnutls26            2.2.2-1           the GNU TLS library - runtime libr
ii  libidn11               1.4-1             GNU libidn library, implementation
ii  libncursesw5           5.6+20080203-1    Shared libraries for terminal hand
ii  libsasl2-2             2.1.22.dfsg1-19   Cyrus SASL - authentication abstra
ii  mutt                   1.5.17+20080114-1 text-based mailreader supporting M
ii  mutt-ng [mutt]         0.0+20060429-3    text-based mailreader supporting M

mutt-patched recommends no packages.

-- no debconf information

# vim:ft=diff:
The draw_sidebar function uses the basename function to decide what to display
on the sidebar for each mailbox folder.  Unfortunately, basename will sometimes
modify the string pointed to by its argument!  This results in the set_curbuffy
function being unable to find your current mailbox (and therefore setting the
cursor to the very top mailbox) if the path to it ends in a '/', e.g.
  imaps://host/

This patch makes a copy of the path member to send to basename, so that the
path doesn't get trashed.

Index: unstable/sidebar.c
===================================================================
--- unstable.orig/sidebar.c     2008-03-20 15:28:04.000000000 -0600
+++ unstable/sidebar.c  2008-03-20 15:34:39.000000000 -0600
@@ -139,6 +139,8 @@
         static int prev_show_value;
         static short saveSidebarWidth;
 
+        char *tmp_path;
+
         /* initialize first time */
         if(!initialized) {
                 prev_show_value = option(OPTSIDEBAR);
@@ -229,8 +231,9 @@
                        tmp->msg_unread = Context->unread;
                        tmp->msgcount = Context->msgcount;
                }
+                tmp_path = safe_strdup(tmp->path);
                 printw( "%.*s", SidebarWidth - delim_len + 1,
-                        make_sidebar_entry(basename(tmp->path), tmp->msgcount,
+                        make_sidebar_entry(basename(tmp_path), tmp->msgcount,
                         tmp->msg_unread));
                lines++;
        }

Reply via email to