[libgdata/libgdata-0-6] gd: Fix attribute escaping for GDataGDWho
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata/libgdata-0-6] gd: Fix attribute escaping for GDataGDWho
- Date: Thu, 30 Sep 2010 18:30:16 +0000 (UTC)
commit fd0cc728f07aada55a26e4b007d410933b478af5
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Sep 30 19:17:59 2010 +0100
gd: Fix attribute escaping for GDataGDWho
gdata/gd/gdata-gd-who.c | 4 ++--
gdata/tests/general.c | 21 +++++++++++++++++++++
2 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/gdata/gd/gdata-gd-who.c b/gdata/gd/gdata-gd-who.c
index d5fb172..7d1bb64 100644
--- a/gdata/gd/gdata-gd-who.c
+++ b/gdata/gd/gdata-gd-who.c
@@ -234,9 +234,9 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
GDataGDWhoPrivate *priv = GDATA_GD_WHO (parsable)->priv;
if (priv->email_address != NULL)
- g_string_append_printf (xml_string, " email='%s'", priv->email_address);
+ gdata_parser_string_append_escaped (xml_string, " email='", priv->email_address, "'");
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 23872c0..1d56cc6 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -2233,6 +2233,26 @@ test_gd_who (void)
}
static void
+test_gd_who_escaping (void)
+{
+ GDataGDWho *who;
+ gchar *xml;
+
+ who = gdata_gd_who_new ("http://schemas.google.com/g/2005#event.attendee?foo&bar", "Value string & stuff!",
+ "John Smith <john smith gmail com>");
+
+ /* Check the outputted XML is escaped properly */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (who));
+ g_assert_cmpstr (xml, ==,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<gd:who xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
+ "email='John Smith <john smith gmail com>' rel='http://schemas.google.com/g/2005#event.attendee?foo&bar' "
+ "valueString='Value string & stuff!'/>");
+ g_free (xml);
+ g_object_unref (who);
+}
+
+static void
test_media_category (void)
{
GDataMediaCategory *category;
@@ -2586,6 +2606,7 @@ main (int argc, char *argv[])
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 ("/gd/who/escaping", test_gd_who_escaping);
g_test_add_func ("/media/category", test_media_category);
g_test_add_func ("/media/content", test_media_content);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]