[libgdata] gcontact: Fix attribute escaping for GDataGContactJot



commit 0cf802f5f3c6f90e04cb6ef5f308ece73dca20e3
Author: Philip Withnall <philip tecnocode co uk>
Date:   Thu Dec 2 12:14:35 2010 +0000

    gcontact: Fix attribute escaping for GDataGContactJot
    
    Helps: bgo#631033

 gdata/gcontact/gdata-gcontact-jot.c |    2 +-
 gdata/tests/general.c               |   19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/gdata/gcontact/gdata-gcontact-jot.c b/gdata/gcontact/gdata-gcontact-jot.c
index d8faa89..8b2637f 100644
--- a/gdata/gcontact/gdata-gcontact-jot.c
+++ b/gdata/gcontact/gdata-gcontact-jot.c
@@ -197,7 +197,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 static void
 pre_get_xml (GDataParsable *parsable, GString *xml_string)
 {
-	g_string_append_printf (xml_string, " rel='%s'", GDATA_GCONTACT_JOT (parsable)->priv->relation_type);
+	gdata_parser_string_append_escaped (xml_string, " rel='", GDATA_GCONTACT_JOT (parsable)->priv->relation_type, "'");
 }
 
 static void
diff --git a/gdata/tests/general.c b/gdata/tests/general.c
index 662cf2b..78c7b87 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -3169,6 +3169,24 @@ test_gcontact_jot_error_handling (void)
 }
 
 static void
+test_gcontact_jot_escaping (void)
+{
+	GDataGContactJot *jot;
+	gchar *xml;
+
+	jot = gdata_gcontact_jot_new ("Content & stuff", "http://foo.com?foo&relation=bar";);
+
+	/* Check the outputted XML is escaped properly */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (jot));
+	g_assert_cmpstr (xml, ==,
+	                 "<?xml version='1.0' encoding='UTF-8'?>"
+	                 "<gContact:jot xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' "
+				"rel='http://foo.com?foo&amp;relation=bar'>Content &amp; stuff</gContact:jot>");
+	g_free (xml);
+	g_object_unref (jot);
+}
+
+static void
 test_gcontact_language (void)
 {
 	GDataGContactLanguage *language, *language2;
@@ -3488,6 +3506,7 @@ main (int argc, char *argv[])
 	g_test_add_func ("/gcontact/external_id/escaping", test_gcontact_external_id_escaping);
 	g_test_add_func ("/gcontact/jot", test_gcontact_jot);
 	g_test_add_func ("/gcontact/jot/error_handling", test_gcontact_jot_error_handling);
+	g_test_add_func ("/gcontact/jot/escaping", test_gcontact_jot_escaping);
 	g_test_add_func ("/gcontact/language", test_gcontact_language);
 	g_test_add_func ("/gcontact/language/error_handling", test_gcontact_language_error_handling);
 	g_test_add_func ("/gcontact/relation", test_gcontact_relation);



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