[libgdata/libgdata-0-6] gd: Fix attribute escaping for GDataGDReminder



commit eb8e779c92d315883c4898c6a44e412cd2b4a92b
Author: Philip Withnall <philip tecnocode co uk>
Date:   Thu Sep 30 19:05:13 2010 +0100

    gd: Fix attribute escaping for GDataGDReminder

 gdata/gd/gdata-gd-reminder.c |    2 +-
 gdata/tests/general.c        |   19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/gdata/gd/gdata-gd-reminder.c b/gdata/gd/gdata-gd-reminder.c
index 6f72814..fa9f1a7 100644
--- a/gdata/gd/gdata-gd-reminder.c
+++ b/gdata/gd/gdata-gd-reminder.c
@@ -272,7 +272,7 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
 	}
 
 	if (priv->method != NULL)
-		g_string_append_printf (xml_string, " method='%s'", priv->method);
+		gdata_parser_string_append_escaped (xml_string, " method='", priv->method, "'");
 }
 
 static void
diff --git a/gdata/tests/general.c b/gdata/tests/general.c
index c5c7bbc..9249cd8 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -1959,6 +1959,24 @@ test_gd_reminder (void)
 }
 
 static void
+test_gd_reminder_escaping (void)
+{
+	GDataGDReminder *reminder;
+	gchar *xml;
+
+	reminder = gdata_gd_reminder_new ("alert?foo&bar", NULL, 15);
+
+	/* Check the outputted XML is escaped properly */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (reminder));
+	g_assert_cmpstr (xml, ==,
+	                 "<?xml version='1.0' encoding='UTF-8'?>"
+	                 "<gd:reminder xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
+	                              "minutes='15' method='alert?foo&amp;bar'/>");
+	g_free (xml);
+	g_object_unref (reminder);
+}
+
+static void
 test_gd_when (void)
 {
 	GDataGDWhen *when, *when2;
@@ -2522,6 +2540,7 @@ main (int argc, char *argv[])
 	g_test_add_func ("/gd/postal_address", test_gd_postal_address);
 	g_test_add_func ("/gd/postal_address/escaping", test_gd_postal_address_escaping);
 	g_test_add_func ("/gd/reminder", test_gd_reminder);
+	g_test_add_func ("/gd/reminder/escaping", test_gd_reminder_escaping);
 	g_test_add_func ("/gd/when", test_gd_when);
 	g_test_add_func ("/gd/where", test_gd_where);
 	g_test_add_func ("/gd/who", test_gd_who);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]