[evolution] M!41 - Ensure CSV imported vCard-s have FN property
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] M!41 - Ensure CSV imported vCard-s have FN property
- Date: Thu, 8 Aug 2019 06:40:11 +0000 (UTC)
commit 884e5b90f013285057a1bb0cc1b5ac7cf50091a2
Author: Дилян Палаузов <git-dpa aegee org>
Date: Thu Jul 4 21:58:46 2019 +0000
M!41 - Ensure CSV imported vCard-s have FN property
and skip byte order mark from the beginning of the file, if present.
Closes https://gitlab.gnome.org/GNOME/evolution/merge_requests/41
Related to https://gitlab.gnome.org/GNOME/evolution/issues/521
src/addressbook/importers/evolution-csv-importer.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/src/addressbook/importers/evolution-csv-importer.c
b/src/addressbook/importers/evolution-csv-importer.c
index 6faee43874..c0ae986940 100644
--- a/src/addressbook/importers/evolution-csv-importer.c
+++ b/src/addressbook/importers/evolution-csv-importer.c
@@ -446,7 +446,7 @@ parseLine (CSVImporter *gci,
gint ii = 0, idx;
gint flags = 0;
gint contact_field;
- EContactAddress *home_address = NULL, *work_address = NULL, *other_address = NULL;
+ EContactAddress *home_address, *work_address, *other_address;
EContactDate *bday = NULL;
GString *home_street, *work_street, *other_street;
home_street = g_string_new ("");
@@ -657,6 +657,9 @@ parseLine (CSVImporter *gci,
ii++;
g_string_free (value, TRUE);
}
+
+ /* This inserts FN: in the vCard. */
+ g_free (e_contact_get (contact, E_CONTACT_FULL_NAME));
home_address->street = g_string_free (home_street, !home_street->len);
work_address->street = g_string_free (work_street, !work_street->len);
other_address->street = g_string_free (other_street, !other_street->len);
@@ -700,6 +703,8 @@ getNextCSVEntry (CSVImporter *gci,
g_string_free (line, TRUE);
return NULL;
}
+ if (c == '\r')
+ c = fgetc (f);
if (c == '\n') {
g_string_append_c (line, c);
break;
@@ -724,6 +729,8 @@ getNextCSVEntry (CSVImporter *gci,
g_string_free (line, TRUE);
return NULL;
}
+ if (c == '\r')
+ c = fgetc (f);
if (c == '\n') {
g_string_append_c (line, c);
break;
@@ -986,6 +993,10 @@ csv_import (EImport *ei,
gci->size = ftell (file);
fseek (file, 0, SEEK_SET);
+ /* Consume byte order mark EF BB BF, if at the beginning of the file */
+ if (fgetc (file) != 0xEF || fgetc (file) != 0xBB || fgetc (file) != 0xBF)
+ fseek (file, 0, SEEK_SET);
+
source = g_datalist_get_data (&target->data, "csv-source");
e_book_client_connect (source, 30, NULL, book_client_connect_cb, gci);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]