[libgdata] contacts: Fix attribute escaping for GDataContactsGroup
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] contacts: Fix attribute escaping for GDataContactsGroup
- Date: Thu, 2 Dec 2010 16:38:15 +0000 (UTC)
commit 82c4747c889d795841ae9c42310c60e421ea7274
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Dec 2 16:37:14 2010 +0000
contacts: Fix attribute escaping for GDataContactsGroup
Helps: bgo#631033
gdata/services/contacts/gdata-contacts-group.c | 5 ++-
gdata/tests/contacts.c | 26 ++++++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/gdata/services/contacts/gdata-contacts-group.c b/gdata/services/contacts/gdata-contacts-group.c
index a61fae4..ca33186 100644
--- a/gdata/services/contacts/gdata-contacts-group.c
+++ b/gdata/services/contacts/gdata-contacts-group.c
@@ -354,8 +354,9 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
static void
get_extended_property_xml_cb (const gchar *name, const gchar *value, GString *xml_string)
{
- /* TODO */
- g_string_append_printf (xml_string, "<gd:extendedProperty name='%s'>%s</gd:extendedProperty>", name, value);
+ /* Note that the value *isn't* escaped (see http://code.google.com/apis/gdata/docs/2.0/elements.html#gdExtendedProperty) */
+ gdata_parser_string_append_escaped (xml_string, "<gd:extendedProperty name='", name, "'>");
+ g_string_append_printf (xml_string, "%s</gd:extendedProperty>", value);
}
static void
diff --git a/gdata/tests/contacts.c b/gdata/tests/contacts.c
index 8a95fa9..c8500f0 100644
--- a/gdata/tests/contacts.c
+++ b/gdata/tests/contacts.c
@@ -846,6 +846,31 @@ test_contact_escaping (void)
}
static void
+test_group_escaping (void)
+{
+ GDataContactsGroup *group;
+ gchar *xml;
+
+ group = gdata_contacts_group_new (NULL);
+ gdata_contacts_group_set_extended_property (group, "extended & prop", "<unescaped>Value should be a pre-escaped XML blob.</unescaped>");
+
+ /* Check the outputted XML is escaped properly */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (group));
+ g_assert_cmpstr (xml, ==,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
+ "xmlns:app='http://www.w3.org/2007/app' xmlns:gContact='http://schemas.google.com/contact/2008'>"
+ "<title type='text'></title>"
+ "<category term='http://schemas.google.com/contact/2008#group' scheme='http://schemas.google.com/g/2005#kind'/>"
+ "<gd:extendedProperty name='extended & prop'>"
+ "<unescaped>Value should be a pre-escaped XML blob.</unescaped>"
+ "</gd:extendedProperty>"
+ "</entry>");
+ g_free (xml);
+ g_object_unref (group);
+}
+
+static void
test_query_uri (void)
{
gchar *query_uri;
@@ -1885,6 +1910,7 @@ main (int argc, char *argv[])
}
g_test_add_func ("/contacts/contact/escaping", test_contact_escaping);
+ g_test_add_func ("/contacts/group/escaping", test_group_escaping);
g_test_add_func ("/contacts/query/uri", test_query_uri);
g_test_add_func ("/contacts/query/etag", test_query_etag);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]