[libgdata] calendar: Fix attribute escaping for GDataCalendarEvent
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] calendar: Fix attribute escaping for GDataCalendarEvent
- Date: Thu, 2 Dec 2010 16:38:05 +0000 (UTC)
commit c6bde418737a0816a839156055e0ebc860443031
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Dec 2 15:58:09 2010 +0000
calendar: Fix attribute escaping for GDataCalendarEvent
Helps: bgo#631033
gdata/services/calendar/gdata-calendar-event.c | 11 +++----
gdata/tests/calendar.c | 36 ++++++++++++++++++++++++
2 files changed, 41 insertions(+), 6 deletions(-)
---
diff --git a/gdata/services/calendar/gdata-calendar-event.c b/gdata/services/calendar/gdata-calendar-event.c
index b3aeb89..a3b7df0 100644
--- a/gdata/services/calendar/gdata-calendar-event.c
+++ b/gdata/services/calendar/gdata-calendar-event.c
@@ -578,16 +578,16 @@ get_xml (GDataParsable *parsable, GString *xml_string)
/* TODO: gd:comments? */
if (priv->status != NULL)
- g_string_append_printf (xml_string, "<gd:eventStatus value='%s'/>", priv->status);
+ gdata_parser_string_append_escaped (xml_string, "<gd:eventStatus value='", priv->status, "'/>");
if (priv->visibility != NULL)
- g_string_append_printf (xml_string, "<gd:visibility value='%s'/>", priv->visibility);
+ gdata_parser_string_append_escaped (xml_string, "<gd:visibility value='", priv->visibility, "'/>");
if (priv->transparency != NULL)
- g_string_append_printf (xml_string, "<gd:transparency value='%s'/>", priv->transparency);
+ gdata_parser_string_append_escaped (xml_string, "<gd:transparency value='", priv->transparency, "'/>");
if (priv->uid != NULL)
- g_string_append_printf (xml_string, "<gCal:uid value='%s'/>", priv->uid);
+ gdata_parser_string_append_escaped (xml_string, "<gCal:uid value='", priv->uid, "'/>");
if (priv->sequence != 0)
g_string_append_printf (xml_string, "<gCal:sequence value='%u'/>", priv->sequence);
@@ -613,7 +613,7 @@ get_xml (GDataParsable *parsable, GString *xml_string)
g_string_append (xml_string, "<gCal:anyoneCanAddSelf value='false'/>");
if (priv->recurrence != NULL)
- g_string_append_printf (xml_string, "<gd:recurrence>%s</gd:recurrence>", priv->recurrence);
+ gdata_parser_string_append_escaped (xml_string, "<gd:recurrence>", priv->recurrence, "</gd:recurrence>");
get_child_xml (priv->times, xml_string);
get_child_xml (priv->people, xml_string);
@@ -622,7 +622,6 @@ get_xml (GDataParsable *parsable, GString *xml_string)
/* TODO:
* - Finish supporting all tags
* - Check all tags here are valid for insertions and updates
- * - Check things are escaped (or not) as appropriate
*/
}
diff --git a/gdata/tests/calendar.c b/gdata/tests/calendar.c
index 9b8c70e..fd066d8 100644
--- a/gdata/tests/calendar.c
+++ b/gdata/tests/calendar.c
@@ -467,6 +467,41 @@ test_calendar_escaping (void)
}
static void
+test_event_escaping (void)
+{
+ GDataCalendarEvent *event;
+ gchar *xml;
+
+ event = gdata_calendar_event_new (NULL);
+ gdata_calendar_event_set_status (event, "<status>");
+ gdata_calendar_event_set_visibility (event, "<visibility>");
+ gdata_calendar_event_set_transparency (event, "<transparency>");
+ gdata_calendar_event_set_uid (event, "<uid>");
+ gdata_calendar_event_set_recurrence (event, "<recurrence>");
+
+ /* Check the outputted XML is escaped properly */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (event));
+ g_assert_cmpstr (xml, ==,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
+ "xmlns:gCal='http://schemas.google.com/gCal/2005' xmlns:app='http://www.w3.org/2007/app'>"
+ "<title type='text'></title>"
+ "<category term='http://schemas.google.com/g/2005#event' scheme='http://schemas.google.com/g/2005#kind'/>"
+ "<gd:eventStatus value='<status>'/>"
+ "<gd:visibility value='<visibility>'/>"
+ "<gd:transparency value='<transparency>'/>"
+ "<gCal:uid value='<uid>'/>"
+ "<gCal:guestsCanModify value='false'/>"
+ "<gCal:guestsCanInviteOthers value='false'/>"
+ "<gCal:guestsCanSeeGuests value='false'/>"
+ "<gCal:anyoneCanAddSelf value='false'/>"
+ "<gd:recurrence><recurrence></gd:recurrence>"
+ "</entry>");
+ g_free (xml);
+ g_object_unref (event);
+}
+
+static void
test_query_uri (void)
{
gint64 _time;
@@ -1003,6 +1038,7 @@ main (int argc, char *argv[])
g_test_add_func ("/calendar/xml/recurrence", test_xml_recurrence);
g_test_add_func ("/calendar/calendar/escaping", test_calendar_escaping);
+ g_test_add_func ("/calendar/event/escaping", test_event_escaping);
g_test_add_func ("/calendar/query/uri", test_query_uri);
g_test_add_func ("/calendar/query/etag", test_query_etag);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]