diff options
author | Milan Crha <mcrha@redhat.com> | 2017-11-27 15:55:00 +0000 |
---|---|---|
committer | Philip Withnall <withnall@endlessm.com> | 2017-11-27 19:11:31 +0000 |
commit | 189a7238f603d15819f62d1cd0e406cc214978d1 (patch) | |
tree | 5cde4abf63c6b5de528edd9ee55d803ff122c4d1 | |
parent | a9c5cbb9788f187470c44d1bc5231cdf249ac8e0 (diff) | |
download | libgdata-189a7238f603d15819f62d1cd0e406cc214978d1.tar.gz |
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
-rw-r--r-- | gdata/services/contacts/gdata-contacts-contact.c | 2 | ||||
-rw-r--r-- | 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 73208028..070ec780 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 48d7011a..e4f72deb 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/>"); |