### Eclipse Workspace Patch 1.0
#P mailsave
Index: mailsave.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mailsave/mailsave.module,v
retrieving revision 1.12
diff -u -r1.12 mailsave.module
--- mailsave.module	28 Oct 2007 13:36:08 -0000	1.12
+++ mailsave.module	7 Mar 2008 22:56:35 -0000
@@ -150,6 +150,18 @@
     $attachment['fid'] = $key;
     $attachment['list'] = 1;
 
+    // Filenames may be encoded, so decode to ensure they work properly
+    $attachment['filename'] = mb_decode_mimeheader($attachment['filename']);
+
+    // Replaces all characters up through space and all past ~ along with the above reserved characters to sanitise filename
+    // from php.net/manual/en/function.preg-replace.php#80431
+
+    // Define characters that are  illegal on any of the 3 major OS's
+    $reserved = preg_quote('\/:*?"<>|', '/');
+
+    // Perform cleanup
+    $attachment['filename'] = preg_replace("/([\\x00-\\x20\\x7f-\\xff{$reserved}])/e", "_", $attachment['filename']);
+
     // Create the $node->files elements
     $node->files[$key] = $attachment;
   }
