Description: Make source and destination path expansion behave more like users expect it
Bug-Debian: https://bugs.debian.org/594049
Bug-Debian: https://bugs.debian.org/759912
Bug-Debian: https://bugs.debian.org/818678
Author: Axel Beckert <abe@debian.org>
Last-Update: 2016-05-22

--- a/mb2md-3.20.pl
+++ b/mb2md-3.20.pl
@@ -412,6 +412,7 @@
 my $dest = undef;
 my $strip_ext = undef;
 my $use_cl = undef;	# defines whether we use the Content-Length: header if present
+my $pwd = `pwd`; chomp($pwd);
 
 # if option "-c" is given, we use the Content-Length: header if present
 # dangerous! may be unreliable, as the whole CL stuff is a bad idea
@@ -444,7 +445,7 @@
 	# it is a subdir of the users $home
 	# if it does start with a "/" then
 	# let's take $mbroot as a absolut path
-	$opts{s} = "$homedir/$opts{s}" if ($opts{s} !~ /^\//); 
+	$opts{s} = "$homedir/$opts{s}" if ($opts{s} !~ m(^[/.]));
 
 	# check if the given source is a mbox file
 	if (-f $opts{s})
@@ -494,13 +495,13 @@
 
 # if the destination is relative to the home dir,
 # check that the home dir exists
-die("Fatal: home dir $homedir doesn't exist.\n") if ($dest !~ /^\// &&  ! -e $homedir);
+die("Fatal: home dir $homedir doesn't exist.\n") if ($dest !~ m(^[/.]) &&  ! -e $homedir);
 
 #
 # form the destination value
 # slap the home dir on the front of the dest if the dest does not begin
 # with a '/'
-$dest = "$homedir/$dest" if ($dest !~ /^\//);
+$dest = "$homedir/$dest" if ($dest !~ m(^[/.]));
 # get rid of trailing /'s
 $dest =~ s/\/$//;
 
@@ -756,6 +757,7 @@
         # Change to the target mailbox directory.
 
         chdir "$maildir" ;
+        $mbox = "$pwd/$mbox" if ($mbox !~ m(^/));
 
          	    # Converts a Mbox to multiple files
                     # in a Maildir.
