[evolution-patches] patch for #70339 (contacts)



This match makes the search for "BEGIN:VCARD", "END:VCARD" in the vcard
string case insensitive. Though standars seems say that they must be in
uppercase it seems some apps send them in lowercase and most apps accept
it.

Siva
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1904
diff -u -r1.1904 ChangeLog
--- ChangeLog	25 Jan 2005 00:28:13 -0000	1.1904
+++ ChangeLog	26 Jan 2005 17:52:44 -0000
@@ -1,3 +1,15 @@
+2005-01-26  Sivaiah Nallagatla <snallagatla novell com>
+
+	* util/eab-book-util.c (strstrcase) :
+	case insesitive version of strstr. Used
+	from camel
+	
+	(eab_contact_list_from_string) : do case in sensitive
+	search for "BEGIN:VCARD" and "END:VCARD" to 
+	take care of broken vcards 
+
+	Fixes #70339 
+
 2005-01-25  Rodrigo Moya <rodrigo novell com>
 
 	* gui/contact-editor/e-contact-editor.c (categories_clicked): use the
Index: util/eab-book-util.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/util/eab-book-util.c,v
retrieving revision 1.10
diff -u -r1.10 eab-book-util.c
--- util/eab-book-util.c	12 Jan 2005 08:39:57 -0000	1.10
+++ util/eab-book-util.c	26 Jan 2005 17:52:45 -0000
@@ -178,6 +178,32 @@
 	return retval;
 }
 
+/* Copied from camel_strstrcase */
+static char *
+strstrcase (const char *haystack, const char *needle)
+{
+	/* find the needle in the haystack neglecting case */
+	const char *ptr;
+	guint len;
+	
+	g_return_val_if_fail (haystack != NULL, NULL);
+	g_return_val_if_fail (needle != NULL, NULL);
+	
+	len = strlen (needle);
+	if (len > strlen (haystack))
+		return NULL;
+	
+	if (len == 0)
+		return (char *) haystack;
+	
+	for (ptr = haystack; *(ptr + len - 1) != '\0'; ptr++)
+		if (!strncasecmp (ptr, needle, len))
+			return (char *) ptr;
+	
+	return NULL;
+}
+
+
 GList*
 eab_contact_list_from_string (const char *str)
 {
@@ -217,21 +243,21 @@
 	 * 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. */
-
-	for (p = strstr (p, "BEGIN:VCARD"); p; p = strstr (q, "\nBEGIN:VCARD")) {
+	
+	for (p = strstrcase (p, "BEGIN:VCARD"); p; p = strstrcase (q, "\nBEGIN:VCARD")) {
 		gchar *card_str;
 
 		if (*p == '\n')
 			p++;
 
-		for (q = strstr (p, "END:VCARD"); q; q = strstr (q, "END:VCARD")) {
+		for (q = strstrcase (p, "END:VCARD"); q; q = strstrcase (q, "END:VCARD")) {
 			gchar *temp;
 
 			q += 9;
 			temp = q;
 			temp += strspn (temp, "\r\n\t ");
 
-			if (*temp == '\0' || !strncmp (temp, "BEGIN:VCARD", 11))
+			if (*temp == '\0' || !strncasecmp (temp, "BEGIN:VCARD", 11))
 				break;  /* Found the outer END:VCARD */
 		}
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]