[libgdata] contacts: Ignore parse errors from websites in contacts
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] contacts: Ignore parse errors from websites in contacts
- Date: Mon, 27 Nov 2017 19:11:59 +0000 (UTC)
commit 189a7238f603d15819f62d1cd0e406cc214978d1
Author: Milan Crha <mcrha redhat com>
Date: Mon Nov 27 15:55:00 2017 +0000
contacts: Ignore parse errors from websites in contacts
It seems the server permits empty websites (with an empty URI) to be
added to contacts. This seems to contradict the specification (or, at
least, is not mentioned as allowed).
https://developers.google.com/google-apps/contacts/v3/reference#gcWebsite
Rather than accepting such nonsensical websites and exposing them to the
user of libgdata to deal with, it seems better to drop them from the
XML. This means that we don’t round-trip perfectly, but I can’t see how
that can cause problems.
https://bugzilla.gnome.org/show_bug.cgi?id=790671
gdata/services/contacts/gdata-contacts-contact.c | 2 +-
gdata/tests/contacts.c | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/gdata/services/contacts/gdata-contacts-contact.c
b/gdata/services/contacts/gdata-contacts-contact.c
index 7320802..070ec78 100644
--- a/gdata/services/contacts/gdata-contacts-contact.c
+++ b/gdata/services/contacts/gdata-contacts-contact.c
@@ -895,7 +895,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
gdata_contacts_contact_add_relation, self,
&success, error) == TRUE ||
gdata_parser_object_from_element_setter (node, "event", P_REQUIRED,
GDATA_TYPE_GCONTACT_EVENT,
gdata_contacts_contact_add_event, self,
&success, error) == TRUE ||
- gdata_parser_object_from_element_setter (node, "website", P_REQUIRED,
GDATA_TYPE_GCONTACT_WEBSITE,
+ gdata_parser_object_from_element_setter (node, "website", P_IGNORE_ERROR,
GDATA_TYPE_GCONTACT_WEBSITE,
gdata_contacts_contact_add_website, self,
&success, error) == TRUE ||
gdata_parser_object_from_element_setter (node, "calendarLink", P_REQUIRED,
GDATA_TYPE_GCONTACT_CALENDAR,
gdata_contacts_contact_add_calendar, self,
&success, error) == TRUE ||
diff --git a/gdata/tests/contacts.c b/gdata/tests/contacts.c
index 48d7011..e4f72de 100644
--- a/gdata/tests/contacts.c
+++ b/gdata/tests/contacts.c
@@ -1435,6 +1435,7 @@ test_contact_parser_normal (void)
"<gContact:website href='http://example.com' rel='home-page' label='Home tab #1'
primary='true'/>"
"<gContact:website href='http://example.com' rel='work'/>"
"<gContact:website href='http://bar.com' rel='profile' primary='false'/>"
+ "<gContact:website href='' rel='other'/>" /* empty on purpose; see bgo#790671 */
"<gContact:event rel='anniversary'><gd:when startTime='2010-03-04'/></gContact:event>"
"<gContact:event label='Foobar'><gd:when startTime='1900-01-01'/></gContact:event>"
"<gContact:calendarLink href='http://example.com/' rel='free-busy' primary='true'/>"
@@ -1512,6 +1513,7 @@ test_contact_parser_normal (void)
/* Websites */
list = gdata_contacts_contact_get_websites (contact);
g_assert_cmpuint (g_list_length (list), ==, 3);
+ /* Note the empty website should *not* be present. See bgo#790671. */
g_assert (GDATA_IS_GCONTACT_WEBSITE (list->data));
g_assert_cmpstr (gdata_gcontact_website_get_uri (GDATA_GCONTACT_WEBSITE (list->data)), ==,
"http://example.com");
@@ -1725,8 +1727,7 @@ test_contact_parser_error_handling (void)
/* gContact:relation */
TEST_XML_ERROR_HANDLING ("<gContact:relation/>");
- /* gContact:website */
- TEST_XML_ERROR_HANDLING ("<gContact:website/>");
+ /* gContact:website errors are ignored (see bgo#790671) */
/* gContact:event */
TEST_XML_ERROR_HANDLING ("<gContact:event/>");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]