[libgdata/libgdata-0-6] gd: Fix attribute escaping for GDataGDIMAddress
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata/libgdata-0-6] gd: Fix attribute escaping for GDataGDIMAddress
- Date: Thu, 30 Sep 2010 18:29:41 +0000 (UTC)
commit 9666fec57e089859a876c47def93636f1ea09386
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Sep 30 17:23:46 2010 +0100
gd: Fix attribute escaping for GDataGDIMAddress
gdata/gd/gdata-gd-im-address.c | 7 +++----
gdata/tests/general.c | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/gdata/gd/gdata-gd-im-address.c b/gdata/gd/gdata-gd-im-address.c
index b5587d9..9a0beea 100644
--- a/gdata/gd/gdata-gd-im-address.c
+++ b/gdata/gd/gdata-gd-im-address.c
@@ -285,13 +285,12 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
{
GDataGDIMAddressPrivate *priv = GDATA_GD_IM_ADDRESS (parsable)->priv;
+ gdata_parser_string_append_escaped (xml_string, " address='", priv->address, "'");
if (priv->protocol != NULL)
- g_string_append_printf (xml_string, " address='%s' protocol='%s'", priv->address, priv->protocol);
- else
- g_string_append_printf (xml_string, " address='%s'", priv->address);
+ gdata_parser_string_append_escaped (xml_string, " protocol='", priv->protocol, "'");
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 61ad24f..d408c91 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -1422,6 +1422,26 @@ test_gd_im_address (void)
}
static void
+test_gd_im_address_escaping (void)
+{
+ GDataGDIMAddress *im;
+ gchar *xml;
+
+ im = gdata_gd_im_address_new ("Fubar <fubar gmail com>", "http://schemas.google.com/g/2005#GOOGLE_TALK?foo&bar",
+ "http://schemas.google.com/g/2005#home?foo&bar", "Personal & Private", TRUE);
+
+ /* Check the outputted XML is escaped properly */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (im));
+ g_assert_cmpstr (xml, ==,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<gd:im xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
+ "address='Fubar <fubar gmail com>' protocol='http://schemas.google.com/g/2005#GOOGLE_TALK?foo&bar' "
+ "rel='http://schemas.google.com/g/2005#home?foo&bar' label='Personal & Private' primary='true'/>");
+ g_free (xml);
+ g_object_unref (im);
+}
+
+static void
test_gd_name (void)
{
GDataGDName *name, *name2;
@@ -2400,6 +2420,7 @@ main (int argc, char *argv[])
g_test_add_func ("/gd/email_address", test_gd_email_address);
g_test_add_func ("/gd/email_address/escaping", test_gd_email_address_escaping);
g_test_add_func ("/gd/im_address", test_gd_im_address);
+ 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/phone_number", test_gd_phone_number);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]