[libgdata] gd: Fix attribute escaping for GDataGDWhere
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [libgdata] gd: Fix attribute escaping for GDataGDWhere
- Date: Thu, 30 Sep 2010 18:19:23 +0000 (UTC)
commit c595f1fac6197838bd831e1bcfaaea0af51950f0
Author: Philip Withnall <philip tecnocode co uk>
Date:   Thu Sep 30 19:13:30 2010 +0100
    gd: Fix attribute escaping for GDataGDWhere
 gdata/gd/gdata-gd-where.c |    2 +-
 gdata/tests/general.c     |   20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/gdata/gd/gdata-gd-where.c b/gdata/gd/gdata-gd-where.c
index 35de40e..63075d1 100644
--- a/gdata/gd/gdata-gd-where.c
+++ b/gdata/gd/gdata-gd-where.c
@@ -249,7 +249,7 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
 		gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
 
 	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->value_string != NULL)
 		gdata_parser_string_append_escaped (xml_string, " valueString='", priv->value_string, "'");
diff --git a/gdata/tests/general.c b/gdata/tests/general.c
index 1323521..3b010f8 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -2273,6 +2273,25 @@ test_gd_where (void)
 }
 
 static void
+test_gd_where_escaping (void)
+{
+	GDataGDWhere *where;
+	gchar *xml;
+
+	where = gdata_gd_where_new (GDATA_GD_WHERE_EVENT "?foo&bar", "Value string & stuff!", "<label>");
+
+	/* Check the outputted XML is escaped properly */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (where));
+	g_assert_cmpstr (xml, ==,
+	                 "<?xml version='1.0' encoding='UTF-8'?>"
+	                 "<gd:where xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
+	                           "label='<label>' rel='http://schemas.google.com/g/2005#event?foo&bar' "
+	                           "valueString='Value string & stuff!'/>");
+	g_free (xml);
+	g_object_unref (where);
+}
+
+static void
 test_gd_who (void)
 {
 	GDataGDWho *who, *who2;
@@ -3268,6 +3287,7 @@ main (int argc, char *argv[])
 	g_test_add_func ("/gd/when", test_gd_when);
 	g_test_add_func ("/gd/when/escaping", test_gd_when_escaping);
 	g_test_add_func ("/gd/where", test_gd_where);
+	g_test_add_func ("/gd/where/escaping", test_gd_where_escaping);
 	g_test_add_func ("/gd/who", test_gd_who);
 
 	g_test_add_func ("/media/category", test_media_category);
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]