[libgdata] [core] Bug 580330 – Rejects empty entry titles
- From: Philip Withnall <pwithnall src gnome org>
- To: svn-commits-list gnome org
- Subject: [libgdata] [core] Bug 580330 – Rejects empty entry titles
- Date: Mon, 27 Apr 2009 14:33:35 -0400 (EDT)
commit 1ebf97cb0f45d12f3b1de608ffab00ba11606e2d
Author: Philip Withnall <philip tecnocode co uk>
Date: Mon Apr 27 17:46:19 2009 +0100
[core] Bug 580330 â?? Rejects empty entry titles
Empty (but present) entry titles now result in GDataEntry:title being set
to an empty string, while non-present titles continue to set it to NULL.
A test case has been added.
---
gdata/gdata-entry.c | 11 +++++++----
gdata/tests/contacts.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/gdata/gdata-entry.c b/gdata/gdata-entry.c
index c1cfa22..20f670c 100644
--- a/gdata/gdata-entry.c
+++ b/gdata/gdata-entry.c
@@ -443,7 +443,12 @@ real_parse_xml (GDataEntry *self, xmlDoc *doc, xmlNode *node, GError **error)
if (xmlStrcmp (node->name, (xmlChar*) "title") == 0) {
/* atom:title */
xmlChar *title = xmlNodeListGetString (doc, node->xmlChildrenNode, TRUE);
- gdata_entry_set_title (self, (gchar*) title);
+
+ /* Title can be empty */
+ if (title == NULL)
+ gdata_entry_set_title (self, "");
+ else
+ gdata_entry_set_title (self, (gchar*) title);
xmlFree (title);
} else if (xmlStrcmp (node->name, (xmlChar*) "id") == 0) {
/* atom:id */
@@ -598,7 +603,7 @@ gdata_entry_get_title (GDataEntry *self)
/**
* gdata_entry_set_title:
* @self: a #GDataEntry
- * @title: the new entry title
+ * @title: the new entry title, or %NULL
*
* Sets the title of the entry.
**/
@@ -606,8 +611,6 @@ void
gdata_entry_set_title (GDataEntry *self, const gchar *title)
{
g_return_if_fail (GDATA_IS_ENTRY (self));
- g_return_if_fail (title != NULL);
-
g_free (self->priv->title);
self->priv->title = g_strdup (title);
g_object_notify (G_OBJECT (self), "title");
diff --git a/gdata/tests/contacts.c b/gdata/tests/contacts.c
index 4e4df19..fb4104e 100644
--- a/gdata/tests/contacts.c
+++ b/gdata/tests/contacts.c
@@ -208,6 +208,39 @@ test_query_uri (void)
g_object_unref (query);
}
+static void
+test_parser_minimal (void)
+{
+ GDataContactsContact *contact;
+ GError *error = NULL;
+
+ g_test_bug ("580330");
+
+ contact = gdata_contacts_contact_new_from_xml (
+ "<entry xmlns='http://www.w3.org/2005/Atom' "
+ "xmlns:gd='http://schemas.google.com/g/2005' "
+ "gd:etag='"QngzcDVSLyp7ImA9WxJTFkoITgU."'>"
+ "<id>http://www.google.com/m8/feeds/contacts/libgdata test googlemail com/base/1b46cdd20bfbee3b</id>"
+ "<updated>2009-04-25T15:21:53.688Z</updated>"
+ "<app:edited xmlns:app='http://www.w3.org/2007/app'>2009-04-25T15:21:53.688Z</app:edited>"
+ "<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/>"
+ "<title></title>" /* Here's where it all went wrong */
+ "<link rel='http://schemas.google.com/contacts/2008/rel#photo' type='image/*' href='http://www.google.com/m8/feeds/photos/media/libgdata test googlemail com/1b46cdd20bfbee3b'/>"
+ "<link rel='self' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/libgdata test googlemail com/full/1b46cdd20bfbee3b'/>"
+ "<link rel='edit' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/libgdata test googlemail com/full/1b46cdd20bfbee3b'/>"
+ "<gd:email rel='http://schemas.google.com/g/2005#other' address='bob example com'/>"
+ "</entry>", -1, &error);
+ g_assert_no_error (error);
+ g_assert (GDATA_IS_ENTRY (contact));
+ g_clear_error (&error);
+
+ /* Check the contact's properties */
+ g_assert (gdata_entry_get_title (GDATA_ENTRY (contact)) != NULL);
+ g_assert (*gdata_entry_get_title (GDATA_ENTRY (contact)) == '\0');
+
+ /* TODO: Check the other properties */
+}
+
int
main (int argc, char *argv[])
{
@@ -225,6 +258,7 @@ main (int argc, char *argv[])
if (g_test_slow () == TRUE)
g_test_add_func ("/contacts/insert/simple", test_insert_simple);
g_test_add_func ("/contacts/query/uri", test_query_uri);
+ g_test_add_func ("/contacts/parser/minimal", test_parser_minimal);
retval = g_test_run ();
if (service != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]