[libgdata/libgdata-0-6] gd: Fix attribute escaping for GDataGDWhen
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata/libgdata-0-6] gd: Fix attribute escaping for GDataGDWhen
- Date: Thu, 30 Sep 2010 18:30:06 +0000 (UTC)
commit e82278624b40a108d095a56ae29011c003b75652
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Sep 30 19:09:55 2010 +0100
gd: Fix attribute escaping for GDataGDWhen
gdata/gd/gdata-gd-when.c | 2 +-
gdata/tests/general.c | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/gdata/gd/gdata-gd-when.c b/gdata/gd/gdata-gd-when.c
index d6c89d8..f3fc7ff 100644
--- a/gdata/gd/gdata-gd-when.c
+++ b/gdata/gd/gdata-gd-when.c
@@ -346,7 +346,7 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
}
if (priv->value_string != NULL)
- g_string_append_printf (xml_string, " valueString='%s'", priv->value_string);
+ gdata_parser_string_append_escaped (xml_string, " valueString='", priv->value_string, "'");
}
static void
diff --git a/gdata/tests/general.c b/gdata/tests/general.c
index 9249cd8..4b5ee35 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -2067,6 +2067,27 @@ test_gd_when (void)
}
static void
+test_gd_when_escaping (void)
+{
+ GDataGDWhen *when;
+ gchar *xml;
+ GTimeVal start_time;
+
+ g_time_val_from_iso8601 ("2005-06-07T01:00:00Z", &start_time);
+ when = gdata_gd_when_new (&start_time, NULL, FALSE);
+ gdata_gd_when_set_value_string (when, "Value string & stuff!");
+
+ /* Check the outputted XML is escaped properly */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (when));
+ g_assert_cmpstr (xml, ==,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<gd:when xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
+ "startTime='2005-06-07T01:00:00Z' valueString='Value string & stuff!'/>");
+ g_free (xml);
+ g_object_unref (when);
+}
+
+static void
test_gd_where (void)
{
GDataGDWhere *where, *where2;
@@ -2542,6 +2563,7 @@ main (int argc, char *argv[])
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/when/escaping", test_gd_when_escaping);
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]