[libgdata] gcontact: Fix attribute escaping for GDataGContactCalendar
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] gcontact: Fix attribute escaping for GDataGContactCalendar
- Date: Thu, 2 Dec 2010 12:24:02 +0000 (UTC)
commit d0060ea09749752aa6c15676beb0467faef0f9f1
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Dec 2 12:01:16 2010 +0000
gcontact: Fix attribute escaping for GDataGContactCalendar
Helps: bgo#631033
gdata/gcontact/gdata-gcontact-calendar.c | 2 +-
gdata/tests/general.c | 32 ++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/gdata/gcontact/gdata-gcontact-calendar.c b/gdata/gcontact/gdata-gcontact-calendar.c
index 48bdbe1..d17b4a9 100644
--- a/gdata/gcontact/gdata-gcontact-calendar.c
+++ b/gdata/gcontact/gdata-gcontact-calendar.c
@@ -279,7 +279,7 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
gdata_parser_string_append_escaped (xml_string, " href='", priv->uri, "'");
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, "'");
else if (priv->label != NULL)
gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
else
diff --git a/gdata/tests/general.c b/gdata/tests/general.c
index c16caa3..d9bc380 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -2816,6 +2816,37 @@ test_gcontact_calendar_error_handling (void)
}
static void
+test_gcontact_calendar_escaping (void)
+{
+ GDataGContactCalendar *calendar;
+ gchar *xml;
+
+ /* Test with rel */
+ calendar = gdata_gcontact_calendar_new ("http://foo.com?foo&bar", "http://foo.com?foo&relation=bar", NULL, TRUE);
+
+ /* Check the outputted XML is escaped properly */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (calendar));
+ g_assert_cmpstr (xml, ==,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<gContact:calendarLink xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' "
+ "href='http://foo.com?foo&bar' rel='http://foo.com?foo&relation=bar' primary='true'/>");
+ g_free (xml);
+ g_object_unref (calendar);
+
+ /* Test with label */
+ calendar = gdata_gcontact_calendar_new ("http://foo.com?foo&bar", NULL, "Label & stuff", FALSE);
+
+ /* Check the outputted XML is escaped properly */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (calendar));
+ g_assert_cmpstr (xml, ==,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<gContact:calendarLink xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' "
+ "href='http://foo.com?foo&bar' label='Label & stuff' primary='false'/>");
+ g_free (xml);
+ g_object_unref (calendar);
+}
+
+static void
test_gcontact_event (void)
{
GDataGContactEvent *event, *event2;
@@ -3378,6 +3409,7 @@ main (int argc, char *argv[])
g_test_add_func ("/gcontact/calendar", test_gcontact_calendar);
g_test_add_func ("/gcontact/calendar/error_handling", test_gcontact_calendar_error_handling);
+ g_test_add_func ("/gcontact/calendar/escaping", test_gcontact_calendar_escaping);
g_test_add_func ("/gcontact/event", test_gcontact_event);
g_test_add_func ("/gcontact/event/error_handling", test_gcontact_event_error_handling);
g_test_add_func ("/gcontact/external_id", test_gcontact_external_id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]