From 949754dc88b8c4fe679d623b82cbe1abab63c966 Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Thu, 6 Dec 2012 13:02:48 -0500
Subject: [PATCH] Remove whitespaces from filenames

---
 include/class.file.php   | 2 +-
 include/class.format.php | 5 +----
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/include/class.file.php b/include/class.file.php
index 364e7f14a..da8ad76dc 100644
--- a/include/class.file.php
+++ b/include/class.file.php
@@ -181,7 +181,7 @@ class AttachmentFile {
         $sql='INSERT INTO '.FILE_TABLE.' SET created=NOW() '
             .',type='.db_input($file['type'])
             .',size='.db_input($file['size'])
-            .',name='.db_input($file['name'])
+            .',name='.db_input(Format::file_name($file['name']))
             .',hash='.db_input($file['hash']);
 
         if (!(db_query($sql) && ($id=db_insert_id())))
diff --git a/include/class.format.php b/include/class.format.php
index aaa6667d3..b510221e0 100644
--- a/include/class.format.php
+++ b/include/class.format.php
@@ -31,10 +31,7 @@ class Format {
     }
 
     function file_name($filename) {
-
-        $search = array('/ß/','/ä/','/Ä/','/ö/','/Ö/','/ü/','/Ü/','([^[:alnum:]._])');
-        $replace = array('ss','ae','Ae','oe','Oe','ue','Ue','_');
-        return preg_replace($search,$replace,$filename);
+        return preg_replace('/\s+/', '_', $filename);
     }
 
     /* re-arrange $_FILES array for the sane */
-- 
GitLab