mirror of
https://github.com/opnsense/core.git
synced 2026-02-18 18:18:13 -05:00
mvc: catch empty data in CSV import
Catch empty lines. A single "," will generate an empty string instead of NULL so we are good here. It's safe to assume we have at least one property in the line, otherwise the data is useless to us anyway. From the fgetcsv() manual: A blank line in a CSV file will be returned as an array comprising a single null field, and will not be treated as an error. See: https://www.php.net/manual/en/function.fgetcsv.php
This commit is contained in:
parent
774a51d626
commit
ed748aef15
1 changed files with 1 additions and 1 deletions
|
|
@ -674,7 +674,7 @@ abstract class ApiMutableModelControllerBase extends ApiControllerBase
|
|||
while (($line = fgetcsv($stream, null, $separator)) !== false) {
|
||||
if (empty($heading)) {
|
||||
$heading = $line;
|
||||
} else {
|
||||
} elseif (count($line) >= 1 && !is_null($line[0])) {
|
||||
$record = [];
|
||||
foreach ($line as $idx => $content) {
|
||||
if (isset($heading[$idx])) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue