[libgdata/libgdata-0-6] gd: Fix attribute escaping for GDataGDPhoneNumber
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata/libgdata-0-6] gd: Fix attribute escaping for GDataGDPhoneNumber
- Date: Thu, 30 Sep 2010 18:29:51 +0000 (UTC)
commit 81fb66634a555150ca61d09cd18909a4300a639f
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Sep 30 18:44:07 2010 +0100
gd: Fix attribute escaping for GDataGDPhoneNumber
gdata/gd/gdata-gd-phone-number.c | 4 ++--
gdata/tests/general.c | 21 +++++++++++++++++++++
2 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/gdata/gd/gdata-gd-phone-number.c b/gdata/gd/gdata-gd-phone-number.c
index b32a0c0..13beabc 100644
--- a/gdata/gd/gdata-gd-phone-number.c
+++ b/gdata/gd/gdata-gd-phone-number.c
@@ -309,9 +309,9 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
GDataGDPhoneNumberPrivate *priv = GDATA_GD_PHONE_NUMBER (parsable)->priv;
if (priv->uri != NULL)
- g_string_append_printf (xml_string, " uri='%s'", priv->uri);
+ gdata_parser_string_append_escaped (xml_string, " uri='", priv->uri, "'");
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 73f4044..ae2820f 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -1720,6 +1720,26 @@ test_gd_phone_number (void)
}
static void
+test_gd_phone_number_escaping (void)
+{
+ GDataGDPhoneNumber *phone;
+ gchar *xml;
+
+ phone = gdata_gd_phone_number_new ("0123456789 <54>", "http://schemas.google.com/g/2005#work_mobile?foo&bar", "Personal & Private",
+ "tel:+012345678954?foo&bar", TRUE);
+
+ /* Check the outputted XML is escaped properly */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (phone));
+ g_assert_cmpstr (xml, ==,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<gd:phoneNumber xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
+ "uri='tel:+012345678954?foo&bar' rel='http://schemas.google.com/g/2005#work_mobile?foo&bar' "
+ "label='Personal & Private' primary='true'>0123456789 <54></gd:phoneNumber>");
+ g_free (xml);
+ g_object_unref (phone);
+}
+
+static void
test_gd_postal_address (void)
{
GDataGDPostalAddress *postal, *postal2;
@@ -2453,6 +2473,7 @@ main (int argc, char *argv[])
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/phone_number/escaping", test_gd_phone_number_escaping);
g_test_add_func ("/gd/postal_address", test_gd_postal_address);
g_test_add_func ("/gd/reminder", test_gd_reminder);
g_test_add_func ("/gd/when", test_gd_when);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]