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



commit 203c9e20e84ac294adc09548bd0e0c4ce8855136
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 e9c71c0..d102b16 100644
--- a/gdata/gd/gdata-gd-where.c
+++ b/gdata/gd/gdata-gd-where.c
@@ -230,7 +230,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 4b5ee35..23872c0 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -2152,6 +2152,25 @@ test_gd_where (void)
 }
 
 static void
+test_gd_where_escaping (void)
+{
+	GDataGDWhere *where;
+	gchar *xml;
+
+	where = gdata_gd_where_new ("http://schemas.google.com/g/2005#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='&lt;label&gt;' rel='http://schemas.google.com/g/2005#event?foo&amp;bar' "
+	                           "valueString='Value string &amp; stuff!'/>");
+	g_free (xml);
+	g_object_unref (where);
+}
+
+static void
 test_gd_who (void)
 {
 	GDataGDWho *who, *who2;
@@ -2565,6 +2584,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]