From 328aaf95be288f1e9037057bc94e334cf98414dc Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Mon, 26 Oct 2009 00:35:21 +0000
Subject: [PATCH] Fix: special char in file name

---
 htdocs/product.class.php | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/htdocs/product.class.php b/htdocs/product.class.php
index 1f73c8df6b5..a17110327ab 100644
--- a/htdocs/product.class.php
+++ b/htdocs/product.class.php
@@ -2389,10 +2389,10 @@ class Product extends CommonObject
 		if (file_exists($dir))
 		{
 			$handle=opendir($dir);
-
 			while (($file = readdir($handle)) != false)
 			{
-				if (is_file($dir.$file)) return true;
+				if (! utf8_check($file)) $file=utf8_encode($file);	// readdir returns ISO
+				if (dol_is_file($dir.$file)) return true;
 			}
 		}
 		return false;
@@ -2418,12 +2418,12 @@ class Product extends CommonObject
 		if (file_exists($dir))
 		{
 			$handle=opendir($dir);
-
 			while (($file = readdir($handle)) != false)
 			{
 				$photo='';
 
-				if (is_file($dir.$file))
+				if (! utf8_check($file)) $file=utf8_encode($file);	// readdir returns ISO
+				if (dol_is_file($dir.$file))
 				{
 					$nbphoto++;
 					$photo = $file;
@@ -2504,7 +2504,6 @@ class Product extends CommonObject
 			while (($file = readdir($handle)) != false)
 			{
 				if (! utf8_check($file)) $file=utf8_encode($file);	// readdir returns ISO
-
 				if (dol_is_file($dir.$file))
 				{
 					$nbphoto++;
-- 
GitLab