Fix CSV header whitespace causing exact match to fail
Trim CSV headers and row values in fetch_remote_csv_data() to prevent whitespace in column names (e.g. "OTP ") from breaking the validation lookup against sanitized field config keys.
This commit is contained in:
@@ -529,8 +529,8 @@ class CHECKER_SHORTCODE extends SHEET_DATA_CHECKER_PRO
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get headers from first line
|
// Get headers from first line (trim to handle whitespace in column names)
|
||||||
$keys = str_getcsv($lines[0], $delimiter);
|
$keys = array_map('trim', str_getcsv($lines[0], $delimiter));
|
||||||
|
|
||||||
// Process data rows
|
// Process data rows
|
||||||
$count = 0;
|
$count = 0;
|
||||||
@@ -539,7 +539,7 @@ class CHECKER_SHORTCODE extends SHEET_DATA_CHECKER_PRO
|
|||||||
continue; // Skip empty lines
|
continue; // Skip empty lines
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = str_getcsv($lines[$i], $delimiter);
|
$row = array_map('trim', str_getcsv($lines[$i], $delimiter));
|
||||||
if (count($keys) === count($row)) {
|
if (count($keys) === count($row)) {
|
||||||
$data[] = array_combine($keys, $row);
|
$data[] = array_combine($keys, $row);
|
||||||
$count++;
|
$count++;
|
||||||
|
|||||||
Reference in New Issue
Block a user