diff --git a/program/lib/Roundcube/rcube_csv2vcard.php b/program/lib/Roundcube/rcube_csv2vcard.php index 38a8e111e4f..0d3442d4550 100644 --- a/program/lib/Roundcube/rcube_csv2vcard.php +++ b/program/lib/Roundcube/rcube_csv2vcard.php @@ -402,9 +402,6 @@ public function __construct($lang = 'en_US') $this->local_label_map = array_merge($this->label_map, $map); } } - - $this->label_map = array_flip($this->label_map); - $this->local_label_map = array_flip($this->local_label_map); } /** @@ -481,7 +478,6 @@ public function get_fields() // get all vcard fields $fields = array_unique($this->csv2vcard_map); $local_field_names = $this->local_label_map ?: $this->label_map; - $local_field_names = array_flip($local_field_names); // translate with the local map $map = []; @@ -539,6 +535,9 @@ protected function parse_header($lines) { $elements = $this->parse_line($lines[0]); + $label_map = array_flip($this->label_map); + $local_label_map = array_flip($this->local_label_map); + if (count($lines) == 2) { // first line of contents needed to properly identify fields in gmail CSV $contents = $this->parse_line($lines[1]); @@ -550,8 +549,8 @@ protected function parse_header($lines) // check English labels for ($i = 0; $i < $size; $i++) { - if (!empty($this->label_map[$elements[$i]])) { - $label = $this->label_map[$elements[$i]]; + if (!empty($label_map[$elements[$i]])) { + $label = $label_map[$elements[$i]]; if ($label && !empty($this->csv2vcard_map[$label])) { $map1[$i] = $this->csv2vcard_map[$label]; } @@ -559,9 +558,9 @@ protected function parse_header($lines) } // check localized labels - if (!empty($this->local_label_map)) { + if (!empty($local_label_map)) { for ($i = 0; $i < $size; $i++) { - $label = $this->local_label_map[$elements[$i]]; + $label = $local_label_map[$elements[$i]]; // special localization label if ($label && $label[0] == '_') {