Skip to content

Commit 93797bf

Browse files
bramleySam Tuke
authored andcommitted
Use str_getcsv() to parse lines of import file (#434)
1 parent 7e6a046 commit 93797bf

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

public_html/lists/admin/actions/import2.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@
2828
$email_list = explode("\n", $email_list); //WARNING the file contents get replace by an array
2929
output(sprintf('..'.$GLOBALS['I18N']->get('ok, %d lines').'</p>', count($email_list)));
3030
$header = array_shift($email_list);
31-
$header = str_replace('"', '', $header);
3231
$total = count($email_list);
33-
$headers = explode($_SESSION['import_field_delimiter'], $header);
32+
$headers = str_getcsv($header, $_SESSION['import_field_delimiter']);
3433
$headers = array_unique($headers);
3534
$_SESSION['columnnames'] = $headers;
3635

@@ -77,10 +76,7 @@
7776
set_time_limit(60);
7877
// will contain attributes to store / change
7978
$user = array();
80-
// get rid of text delimiters generally added by spreadsheet apps
81-
$line = str_replace('"', '', $line);
82-
83-
$values = explode($_SESSION['import_field_delimiter'], $line);
79+
$values = str_getcsv($line, $_SESSION['import_field_delimiter']);
8480
$system_values = array();
8581
foreach ($system_attribute_mapping as $column => $index) {
8682
// print '<br/>'.$column . ' = '. $values[$index];

public_html/lists/admin/import2.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,8 @@
219219
$email_list = explode("\n", $email_list); //WARNING the file contents get replace by an array
220220
output(sprintf('..'.$GLOBALS['I18N']->get('ok, %d lines').'</p>', count($email_list)));
221221
$header = array_shift($email_list);
222-
$header = str_replace('"', '', $header);
223222
$total = count($email_list);
224-
$headers = explode($_SESSION['import_field_delimiter'], $header);
223+
$headers = str_getcsv($header, $_SESSION['import_field_delimiter']);
225224
$headers = array_unique($headers);
226225
$_SESSION['columnnames'] = $headers;
227226

@@ -506,10 +505,7 @@
506505
set_time_limit(60);
507506
// will contain attributes to store / change
508507
$user = array();
509-
// get rid of text delimiters generally added by spreadsheet apps
510-
$line = str_replace('"', '', $line);
511-
512-
$values = explode($_SESSION['import_field_delimiter'], $line);
508+
$values = str_getcsv($line, $_SESSION['import_field_delimiter']);
513509
$system_values = array();
514510
foreach ($system_attribute_mapping as $column => $index) {
515511
// print '<br/>'.$column . ' = '. $values[$index];

0 commit comments

Comments
 (0)