diff options
Diffstat (limited to 'addressbook/util/eab-book-util.c')
-rw-r--r-- | addressbook/util/eab-book-util.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/addressbook/util/eab-book-util.c b/addressbook/util/eab-book-util.c index a1ff103eeb..473d386f54 100644 --- a/addressbook/util/eab-book-util.c +++ b/addressbook/util/eab-book-util.c @@ -178,6 +178,32 @@ eab_nickname_query (EBook *book, return retval; } +/* Copied from camel_strstrcase */ +static char * +eab_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 (!g_ascii_strncasecmp (ptr, needle, len)) + return (char *) ptr; + + return NULL; +} + + GList* eab_contact_list_from_string (const char *str) { @@ -217,21 +243,21 @@ eab_contact_list_from_string (const char *str) * 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 = eab_strstrcase (p, "BEGIN:VCARD"); p; p = eab_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 = eab_strstrcase (p, "END:VCARD"); q; q = eab_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' || !g_ascii_strncasecmp (temp, "BEGIN:VCARD", 11)) break; /* Found the outer END:VCARD */ } |