mirror of
https://github.com/itflow-org/itflow
synced 2026-12-05 10:39:00 +00:00
CSV imports keep accented letters: csvTextToUtf8 reads an upload as UTF-8 whether it was saved as UTF-8, UTF-16, Windows-1252 or Mac Roman, used by every import window kind, bank statements on Expenses and Income, and the network IP and interface imports; tab separated files import; the import answer survives a bad byte; 26.12.6 changelog and CONTRIBUTING rule
This commit is contained in:
@@ -351,7 +351,10 @@ if (isset($_POST['import_client_asset_interfaces_csv'])) {
|
||||
redirect();
|
||||
}
|
||||
|
||||
$file = fopen($_FILES['file']['tmp_name'], 'r');
|
||||
// As UTF-8 whatever the spreadsheet saved it as
|
||||
$file = fopen('php://temp', 'r+');
|
||||
fwrite($file, csvTextToUtf8((string) @file_get_contents($_FILES['file']['tmp_name'])));
|
||||
rewind($file);
|
||||
$header = fgetcsv($file, 1000, ',');
|
||||
if (!is_array($header) || !in_array(count($header), [8, 9], true)) {
|
||||
fclose($file);
|
||||
|
||||
@@ -17,7 +17,7 @@ if (isset($_POST['import_check']) || isset($_POST['import_run'])) {
|
||||
|
||||
$answer = function (array $answer) {
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode($answer);
|
||||
echo json_encode($answer, JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
exit;
|
||||
};
|
||||
|
||||
|
||||
@@ -266,7 +266,10 @@ if (isset($_POST['import_network_ips_csv'])) {
|
||||
redirect();
|
||||
}
|
||||
|
||||
$file = fopen($_FILES['file']['tmp_name'], 'r');
|
||||
// As UTF-8 whatever the spreadsheet saved it as
|
||||
$file = fopen('php://temp', 'r+');
|
||||
fwrite($file, csvTextToUtf8((string) @file_get_contents($_FILES['file']['tmp_name'])));
|
||||
rewind($file);
|
||||
$header = fgetcsv($file, 1000, ',');
|
||||
if (!is_array($header) || !in_array(count($header), [3, 5], true)) {
|
||||
fclose($file);
|
||||
|
||||
Reference in New Issue
Block a user