Merge pull request #763 from slimtim/bug_4133
When importing a CSV file force a trailing new line at EOF (bug #4133)
This commit is contained in:
commit
240d37e3f1
@ -259,6 +259,22 @@ class ImportCsv extends AbstractImportCsv
|
||||
// Append new data to buffer
|
||||
$buffer .= $data;
|
||||
unset($data);
|
||||
|
||||
// Force a trailing new line at EOF to prevent parsing problems
|
||||
if ($finished && $buffer) {
|
||||
$finalch = substr($buffer, -1);
|
||||
if ($csv_new_line == 'auto'
|
||||
&& $finalch != "\r"
|
||||
&& $finalch != "\n"
|
||||
) {
|
||||
$buffer .= "\n";
|
||||
} elseif ($csv_new_line != 'auto'
|
||||
&& $finalch != $csv_new_line
|
||||
) {
|
||||
$buffer .= $csv_new_line;
|
||||
}
|
||||
}
|
||||
|
||||
// Do not parse string when we're not at the end
|
||||
// and don't have new line inside
|
||||
if (($csv_new_line == 'auto'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user