[evolution-patches] [Addressbook] Fix for 66369
- From: Hans Petter Jansson <hpj ximian com>
- To: evolution-patches lists ximian com
- Subject: [evolution-patches] [Addressbook] Fix for 66369
- Date: Tue, 21 Sep 2004 21:18:38 -0500
Attached patch fixes this specific case and adds some commentary on what
we should really be doing. Intended for HEAD and gnome-2-8.
--
Hans Petter
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1822.2.4
diff -u -p -r1.1822.2.4 ChangeLog
--- ChangeLog 16 Sep 2004 14:45:53 -0000 1.1822.2.4
+++ ChangeLog 22 Sep 2004 02:14:25 -0000
@@ -1,3 +1,10 @@
+2004-09-21 Hans Petter Jansson <hpj ximian com>
+
+ Fixes #66369.
+
+ * util/eab-book-util.c (eab_contact_list_from_string): Make the
+ vcard splitter work with any amount of blank lines between vcards.
+
2004-09-13 Rodney Dawes <dobey novell com>
* gui/contact-editor/e-contact-editor.c (show_help_cb):
Index: util/eab-book-util.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/util/eab-book-util.c,v
retrieving revision 1.7
diff -u -p -r1.7 eab-book-util.c
--- util/eab-book-util.c 24 Jun 2004 22:49:00 -0000 1.7
+++ util/eab-book-util.c 22 Sep 2004 02:14:26 -0000
@@ -69,7 +69,6 @@ escape (const char *str)
return g_string_free (s, FALSE);
}
-
guint
eab_name_and_email_query (EBook *book,
const gchar *name,
@@ -186,7 +185,6 @@ eab_contact_list_from_string (const char
GString *gstr = g_string_new ("");
char *p = (char*)str;
char *q;
- char *blank_line;
if (!p)
return NULL;
@@ -208,33 +206,33 @@ eab_contact_list_from_string (const char
p = g_string_free (gstr, FALSE);
q = p;
- do {
- char *temp;
- blank_line = strstr (q, "\n\n");
- if (blank_line) {
- temp = g_strndup (q, blank_line - q);
- }
- else {
- temp = g_strdup (q);
- }
+ /* Note: The VCard standard says
+ *
+ * vcard = "BEGIN" [ws] ":" [ws] "VCARD" [ws] 1*CRLF
+ * items *CRLF "END" [ws] ":" [ws] "VCARD"
+ *
+ * which means we can have whitespace (e.g. "BEGIN : VCARD"). So we're not being
+ * fully compliant here, although I'm not sure it matters. The ideal solution
+ * would be to have a vcard parsing function that returned the end of the vcard
+ * parsed. Arguably, contact list parsing should all be in libebook's e-vcard.c,
+ * where we can do proper parsing and validation without code duplication. */
- /* Do a minimal well-formedness test, since
- * e_contact_new_from_vcard () always returns a contact */
- if (!strstr (p, "BEGIN:VCARD")) {
- g_free (temp);
- break;
- }
+ for (p = strstr (p, "BEGIN:VCARD"); p; p = strstr (q, "\nBEGIN:VCARD")) {
+ gchar *card_str;
- contacts = g_list_append (contacts, e_contact_new_from_vcard (temp));
+ if (*p == '\n')
+ p++;
- g_free (temp);
+ q = strstr (p, "END:VCARD");
+ if (!q)
+ break;
- if (blank_line)
- q = blank_line + 2;
- else
- q = NULL;
- } while (blank_line);
+ q += 9;
+ card_str = g_strndup (p, q - p);
+ contacts = g_list_append (contacts, e_contact_new_from_vcard (card_str));
+ g_free (card_str);
+ }
g_free (p);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]