Skip to content
Permalink
Browse files

Improved error handling of CSV lines with less than 4 fields

Fixes #122
  • Loading branch information...
LarsMichelsen committed Jun 1, 2019
1 parent 0cf1d08 commit 8f81473d9330aa4cb6537b3b0b6ccee86d7c39a1
Showing with 10 additions and 0 deletions.
  1. +3 −0 ChangeLog
  2. +7 −0 share/server/core/sources/geomap.php
@@ -2,6 +2,9 @@
Frontend
* FIX: Fixed incompatibility with PHP 7.2 (count(STRING)) when creating roles

Geomap:
* Improved error handling of CSV lines with less than 4 fields

1.9.11
Frontend
* FIX: Weathermap lines now respect the configured error colors
@@ -20,11 +20,18 @@ function geomap_read_csv($p) {
if(!file_exists($f))
throw new GeomapError(l('Location source file "[F]" does not exist.', Array('F' => $f)));
$i = 0;
foreach(file($f) AS $line) {
$i++;
// skip lines beginning with any of the usual comment characters
if(preg_match('/^[;#\/]/',$line))
continue;
$parts = explode(';', $line);
if (count($parts) < 4)
throw new GeomapError(l('Invalid source file line found: Line "[NR]" in "[F]" '
.'has less than 4 fields', Array('NR' => $i, 'F' => $f)));
$locations[] = array(
'name' => $parts[0],
'alias' => $parts[1],

0 comments on commit 8f81473

Please sign in to comment.
You can’t perform that action at this time.