Index: src/include/lib/Garradin/Membres/Import.php ================================================================== --- src/include/lib/Garradin/Membres/Import.php +++ src/include/lib/Garradin/Membres/Import.php @@ -15,11 +15,11 @@ if (!file_exists($path) || !is_readable($path)) { throw new \RuntimeException('Fichier inconnu : '.$path); } - $fp = fopen($path, 'r'); + $fp = Utils::open_csv_file($path); if (!$fp) { return false; } @@ -177,11 +177,11 @@ if (!file_exists($path) || !is_readable($path)) { throw new \RuntimeException('Fichier inconnu : '.$path); } - $fp = fopen($path, 'r'); + $fp = Utils::open_csv_file($path); if (!$fp) { return false; } Index: src/include/lib/Garradin/Utils.php ================================================================== --- src/include/lib/Garradin/Utils.php +++ src/include/lib/Garradin/Utils.php @@ -618,20 +618,30 @@ $url .= $params['query']; } return $url; } + + static public function open_csv_file($file) + { + ini_set('auto_detect_line_endings', true); + return fopen($file, 'r'); + } static public function find_csv_delim(&$fp) { $line = ''; while ($line === '' && !feof($fp)) { - $line = trim(fgets($fp, 4096)); + $line = fgets($fp, 4096); + } + + if (strlen($line) >= 4095) { + throw new UserException('Fichier CSV illisible : la première ligne est trop longue.'); } - + // Delete the columns content $line = preg_replace('/".*?"/', '', $line); $delims = [ ';' => substr_count($line, ';'), Index: src/templates/admin/membres/import.tpl ================================================================== --- src/templates/admin/membres/import.tpl +++ src/templates/admin/membres/import.tpl @@ -58,10 +58,11 @@