--- Message.pm.4.32.3.orig	2004-07-27 18:16:29.000000000 +0100
+++ Message.pm	2004-07-27 01:18:25.000000000 +0100
@@ -1418,7 +1418,7 @@
   return 1 if ($name =~ m{^\.+\Z});         ### dots
   return 1 if ($name =~ tr{ \%\(\)\+\,\-\.0-9\=A-Z_a-z\{\}\x80-\xFF}{}c);
   return 1 if (length($name) > 50);
-  return 1 if (-e "$dir/$name");
+  return 'exists' if (-e "$dir/$name");
 
   #print STDERR "It is okay\n";
   #$self->debug("it's ok");
@@ -1433,6 +1433,7 @@
     my $last = $fname; $last =~ s{^.*[/\\\[\]:]}{};
     if ($last and !$self->IsNameEvil($last, $dir)) {
         #$self->debug("looks like I can use the last path element");
+        #print STDERR "MakeNameSafe: 1 $fname,$last\n";
         return $last;
     }
 
@@ -1441,6 +1442,7 @@
     $last =~ s/^\s+//;
     $last =~ s/\s+\Z//;
     $last =~ tr/ \%\(\)\+\,\-\.0-9\=A-Z_a-z\{\}\x80-\xFF//cd;
+    #print STDERR "MakeNameSafe: 2 $fname,$last\n";
     return $last unless $self->IsNameEvil($last, $dir);
 
     ### Break last element into root and extension, and truncate:
@@ -1456,10 +1458,22 @@
     my $trunc = $root . ($ext ? ".$ext" : '');
     if (!$self->IsNameEvil($trunc, $dir)) {
         #$self->debug("looks like I can use the truncated last path element");
+        #print STDERR "MakeNameSafe: 3 $fname,$trunc\n";
         return $trunc;
     }
 
+    # It is still evil, but probably just because it exists
+    if ($self->IsNameEvil($trunc, $dir) eq 'exists') {
+      my $counter = 0;
+      $trunc = $trunc . '0';
+      do {
+        $counter++;
+        $trunc = $root . $counter . ($ext ? ".$ext" : '');
+      } while $self->IsNameEvil($trunc, $dir) eq 'exists';
+      return $trunc;
+    }
     ### Hope that works:
+    #print STDERR "MakeNameSafe: 4 $fname,:-(\n";
     undef;
 }
 
