[libgdata] gd: Fix attribute escaping for GDataGDOrganization
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] gd: Fix attribute escaping for GDataGDOrganization
- Date: Thu, 30 Sep 2010 18:18:58 +0000 (UTC)
commit 135b790ca479085fec78e8f37de302cf2d04515c
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Sep 30 17:31:48 2010 +0100
gd: Fix attribute escaping for GDataGDOrganization
gdata/gd/gdata-gd-organization.c | 2 +-
gdata/tests/general.c | 28 ++++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/gdata/gd/gdata-gd-organization.c b/gdata/gd/gdata-gd-organization.c
index 7168850..0472f90 100644
--- a/gdata/gd/gdata-gd-organization.c
+++ b/gdata/gd/gdata-gd-organization.c
@@ -425,7 +425,7 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
GDataGDOrganizationPrivate *priv = GDATA_GD_ORGANIZATION (parsable)->priv;
if (priv->relation_type != NULL)
- g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
+ gdata_parser_string_append_escaped (xml_string, " rel='", priv->relation_type, "'");
if (priv->label != NULL)
gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
diff --git a/gdata/tests/general.c b/gdata/tests/general.c
index 03fcee0..c05d71f 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -1754,6 +1754,33 @@ test_gd_organization (void)
}
static void
+test_gd_organization_escaping (void)
+{
+ GDataGDOrganization *org;
+ gchar *xml;
+
+ org = gdata_gd_organization_new ("Steptoe & Son", "Title & Stuff", GDATA_GD_ORGANIZATION_WORK "?foo&bar", "Personal & Private", TRUE);
+ gdata_gd_organization_set_department (org, "Department & Stuff");
+ gdata_gd_organization_set_job_description (org, "Escaping <brackets>.");
+ gdata_gd_organization_set_symbol (org, "<&>");
+
+ /* Check the outputted XML is escaped properly */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (org));
+ g_assert_cmpstr (xml, ==,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<gd:organization xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
+ "rel='http://schemas.google.com/g/2005#work?foo&bar' label='Personal & Private' primary='true'>"
+ "<gd:orgName>Steptoe & Son</gd:orgName>"
+ "<gd:orgTitle>Title & Stuff</gd:orgTitle>"
+ "<gd:orgDepartment>Department & Stuff</gd:orgDepartment>"
+ "<gd:orgJobDescription>Escaping <brackets>.</gd:orgJobDescription>"
+ "<gd:orgSymbol><&></gd:orgSymbol>"
+ "</gd:organization>");
+ g_free (xml);
+ g_object_unref (org);
+}
+
+static void
test_gd_phone_number (void)
{
GDataGDPhoneNumber *phone, *phone2;
@@ -3127,6 +3154,7 @@ main (int argc, char *argv[])
g_test_add_func ("/gd/im_address/escaping", test_gd_im_address_escaping);
g_test_add_func ("/gd/name", test_gd_name);
g_test_add_func ("/gd/organization", test_gd_organization);
+ g_test_add_func ("/gd/organization/escaping", test_gd_organization_escaping);
g_test_add_func ("/gd/phone_number", test_gd_phone_number);
g_test_add_func ("/gd/postal_address", test_gd_postal_address);
g_test_add_func ("/gd/reminder", test_gd_reminder);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]