diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index f6316a44975a2c7c57fc76789630935294f4cf28..a8c268ccfee12429956575852446005d6b8e45ef 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -1817,7 +1817,7 @@ if ($action == 'presend')
 {
 	$ref = dol_sanitizeFileName($object->ref);
     include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-    $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref);
+    $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
     $file=$fileparams['fullname'];
 
     // Build document if it not exists
@@ -1840,7 +1840,7 @@ if ($action == 'presend')
             dol_print_error($db,$result);
             exit;
         }
-        $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref);
+        $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
         $file=$fileparams['fullname'];
     }
 
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 8acf2ae85af6ff286afb87289eeaf7d5aeea7510..167f4c53268c2a8b0e6e1f028808f09da8d5c562 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -204,14 +204,14 @@ else if ($action == 'add' && $user->rights->commande->creer)
 		$action='create';
 		$error++;
 	}
-	
+
 	if (! $error)
 	{
 		$object->socid=$socid;
 		$object->fetch_thirdparty();
-	
+
 		$db->begin();
-	
+
 		$object->date_commande        = $datecommande;
 		$object->note                 = GETPOST('note');
 		$object->note_public          = GETPOST('note_public');
@@ -226,7 +226,7 @@ else if ($action == 'add' && $user->rights->commande->creer)
 		$object->date_livraison       = $datelivraison;
 		$object->fk_delivery_address  = GETPOST('fk_address');
 		$object->contactid            = GETPOST('contactidp');
-	
+
 		// If creation from another object of another module (Example: origin=propal, originid=1)
 		if (! empty($origin) && ! empty($originid))
 		{
@@ -237,7 +237,7 @@ else if ($action == 'add' && $user->rights->commande->creer)
 				$element = $regs[1];
 				$subelement = $regs[2];
 			}
-	
+
 			// For compatibility
 			if ($element == 'order')    {
 				$element = $subelement = 'commande';
@@ -248,10 +248,10 @@ else if ($action == 'add' && $user->rights->commande->creer)
 			if ($element == 'contract') {
 				$element = $subelement = 'contrat';
 			}
-	
+
 			$object->origin    = $origin;
 			$object->origin_id = $originid;
-	
+
 			// Possibility to add external linked objects with hooks
 			$object->linked_objects[$object->origin] = $object->origin_id;
 			$other_linked_objects=GETPOST('other_linked_objects','array');
@@ -259,32 +259,32 @@ else if ($action == 'add' && $user->rights->commande->creer)
 			{
 				$object->linked_objects = array_merge($object->linked_objects, $other_linked_objects);
 			}
-	
+
 			$object_id = $object->create($user);
-	
+
 			if ($object_id > 0)
 			{
 				dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
-	
+
 				$classname = ucfirst($subelement);
 				$srcobject = new $classname($db);
-	
+
 				dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
 				$result=$srcobject->fetch($object->origin_id);
 				if ($result > 0)
 				{
 					$lines = $srcobject->lines;
 					if (empty($lines) && method_exists($srcobject,'fetch_lines'))  $lines = $srcobject->fetch_lines();
-	
+
 					$fk_parent_line=0;
 					$num=count($lines);
-	
+
 					for ($i=0;$i<$num;$i++)
 					{
 						$label=(! empty($lines[$i]->label)?$lines[$i]->label:'');
 						$desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle);
 						$product_type=(! empty($lines[$i]->product_type)?$lines[$i]->product_type:0);
-	
+
 						// Dates
 						// TODO mutualiser
 						$date_start=$lines[$i]->date_debut_prevue;
@@ -293,12 +293,12 @@ else if ($action == 'add' && $user->rights->commande->creer)
 						$date_end=$lines[$i]->date_fin_prevue;
 						if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
 						if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
-	
+
 						// Reset fk_parent_line for no child products and special product
 						if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
 							$fk_parent_line = 0;
 						}
-	
+
 						$result = $object->addline(
 							$object_id,
 							$desc,
@@ -323,19 +323,19 @@ else if ($action == 'add' && $user->rights->commande->creer)
 							$lines[$i]->pa_ht,
 							$label
 						);
-	
+
 						if ($result < 0)
 						{
 							$error++;
 							break;
 						}
-	
+
 						// Defined the new fk_parent_line
 						if ($result > 0 && $lines[$i]->product_type == 9) {
 							$fk_parent_line = $result;
 						}
 					}
-	
+
 					// Hooks
 					$parameters=array('objFrom'=>$srcobject);
 					$reshook=$hookmanager->executeHooks('createFrom',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
@@ -356,7 +356,7 @@ else if ($action == 'add' && $user->rights->commande->creer)
 		else
 		{
 			$object_id = $object->create($user);
-	
+
 			// If some invoice's lines already known
 			$NBLINES=8;
 			for ($i = 1 ; $i <= $NBLINES ; $i++)
@@ -370,7 +370,7 @@ else if ($action == 'add' && $user->rights->commande->creer)
 				}
 			}
 		}
-	
+
 		// Insert default contacts if defined
 		if ($object_id > 0)
 		{
@@ -383,11 +383,11 @@ else if ($action == 'add' && $user->rights->commande->creer)
 					$error++;
 				}
 			}
-	
+
 			$id = $object_id;
 			$action = '';
 		}
-	
+
 		// End of object creation, we show it
 		if ($object_id > 0 && ! $error)
 		{
@@ -1405,7 +1405,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
 				$dateinvoice		= empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
 
 				$datedelivery		= (!empty($objectsrc->date_livraison)?$objectsrc->date_livraison:'');
-				
+
 				$note_private		= (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : ''));
 				$note_public		= (! empty($objectsrc->note_public) ? $objectsrc->note_public : '');
 
@@ -2347,7 +2347,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
 			{
 				$ref = dol_sanitizeFileName($object->ref);
 				include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-				$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref);
+				$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
 				$file=$fileparams['fullname'];
 
 				// Build document if it not exists
@@ -2370,7 +2370,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
 						dol_print_error($db,$result);
 						exit;
 					}
-					$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref);
+					$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
 					$file=$fileparams['fullname'];
 				}
 
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 815ead2cf09d87a6ceea62be9a797e97158bfa77..bd1e21157def76c454abe5402d5ca64932048c69 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -2689,7 +2689,7 @@ else if ($id > 0 || ! empty($ref))
         {
             $num = $db->num_rows($result);
             $i = 0;
-			
+
 			//if ($object->type != 2)
             //{
                 if ($num > 0)
@@ -3343,7 +3343,7 @@ else if ($id > 0 || ! empty($ref))
 
             $ref = dol_sanitizeFileName($object->ref);
             include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-            $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref);
+            $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
             $file=$fileparams['fullname'];
 
             // Build document if it not exists
@@ -3366,7 +3366,7 @@ else if ($id > 0 || ! empty($ref))
                     dol_print_error($db,$result);
                     exit;
                 }
-                $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref);
+                $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
                 $file=$fileparams['fullname'];
             }
 
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index 3285301750f88dff0b1bd76fe09ea602f6d1422f..73cece06e2203c4eb19fdbe9e9d1477f91ec7aaf 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -140,7 +140,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
 							if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file);
 							if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file);
 
-							if (! $filter || preg_match('/'.$filter.'/i',$path.'/'.$file))
+							if (! $filter || preg_match('/'.$filter.'/i',$file))	// We do not search key $filter into $path, only into $file
 							{
 								$file_list[] = array(
 										"name" => $file,
@@ -164,7 +164,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
 						if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file);
 						if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file);
 
-						if (! $filter || preg_match('/'.$filter.'/i',$path.'/'.$file))
+						if (! $filter || preg_match('/'.$filter.'/i',$file))	// We do not search key $filter into $path, only into $file
 						{
 							$file_list[] = array(
 									"name" => $file,
diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index 8a9685669d00a00c009cdbbcc62fe7cb8bf774e2..8992048f14bbb96168025c6ef8d4bb2f43993a26 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -1407,7 +1407,7 @@ else
         {
             $ref = dol_sanitizeFileName($object->ref);
             include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-            $fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref);
+            $fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref, preg_quote($object->ref,'/'));
             $file=$fileparams['fullname'];
 
             // Build document if it not exists
@@ -1430,7 +1430,7 @@ else
                     dol_print_error($db,$result);
                     exit;
                 }
-                $fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref);
+                $fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref, preg_quote($object->ref,'/'));
                 $file=$fileparams['fullname'];
             }
 
diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php
index 6694a20684c71270db65df3d3b1ea544123efff6..1f27c594908af60a114a8f8f2cbdbfa49b5cbc60 100644
--- a/htdocs/fichinter/fiche.php
+++ b/htdocs/fichinter/fiche.php
@@ -1451,7 +1451,7 @@ else if ($id > 0 || ! empty($ref))
     {
         $ref = dol_sanitizeFileName($object->ref);
         include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-        $fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref);
+        $fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
         $file=$fileparams['fullname'];
 
         // Build document if it not exists
@@ -1474,7 +1474,7 @@ else if ($id > 0 || ! empty($ref))
                 dol_print_error($db,$result);
                 exit;
             }
-            $fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref);
+            $fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
             $file=$fileparams['fullname'];
         }
 
diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index c055642803dd297eafeb0131f62c9a84d3cfac01..348f296ff89676e39108a3a29797586dec6096b0 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -1071,7 +1071,7 @@ if (! empty($object->id))
 		if($mysoc->localtax1_assuj=="1") $nbrow++;
 		if($object->thirdparty->localtax2_assuj=="1") $nbrow++;
 	}
-	else 
+	else
 	{
 		if($mysoc->localtax1_assuj=="1") $nbrow++;
 		if($mysoc->localtax2_assuj=="1") $nbrow++;
@@ -1245,7 +1245,7 @@ if (! empty($object->id))
 			print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
 		}
 	}
-	else 
+	else
 	{
 		if ($mysoc->localtax1_assuj=="1") //Localtax1
 		{
@@ -1783,7 +1783,7 @@ if (! empty($object->id))
 	{
 		$ref = dol_sanitizeFileName($object->ref);
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-		$fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref);
+		$fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
 		$file=$fileparams['fullname'];
 
 		// Build document if it not exists
@@ -1806,7 +1806,7 @@ if (! empty($object->id))
 				dol_print_error($db,$result);
 				exit;
 			}
-			$fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref);
+			$fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
 			$file=$fileparams['fullname'];
 		}
 
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index 8e6b66e71bd59760b98dc553cff7747027bde629..f15dcd6711499be7542f298358033ec454c599d8 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -2036,7 +2036,7 @@ else
         {
             $ref = dol_sanitizeFileName($object->ref);
             include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-            $fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref);
+            $fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref, preg_quote($object->ref,'/'));
             $file=$fileparams['fullname'];
 
             // Build document if it not exists
@@ -2059,7 +2059,7 @@ else
                     dol_print_error($db,$result);
                     exit;
                 }
-                $fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref);
+                $fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref, preg_quote($object->ref,'/'));
                 $file=$fileparams['fullname'];
             }
 
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index 1e9f9a67e7f4ffeb86a1c95c31d0e7d5e1d2af9c..aa3e808366b881c789ef6ed78589c19319128225 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -239,7 +239,10 @@ input:-webkit-autofill {
 input.liste_titre {
 	box-shadow: none !important;
 }
-
+input.removedfile {
+	padding: 0px !important;
+	border: 0px !important;
+}
 textarea:disabled {
 	background:#ddd;
 }