[libgdata] gcontact: Fix attribute escaping for GDataGContactEvent
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] gcontact: Fix attribute escaping for GDataGContactEvent
- Date: Thu, 2 Dec 2010 12:24:07 +0000 (UTC)
commit 1645782428aaf608bce29915641a91da3568ab20
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Dec 2 12:08:16 2010 +0000
gcontact: Fix attribute escaping for GDataGContactEvent
Helps: bgo#631033
gdata/gcontact/gdata-gcontact-event.c | 2 +-
gdata/tests/general.c | 40 +++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 1 deletions(-)
---
diff --git a/gdata/gcontact/gdata-gcontact-event.c b/gdata/gcontact/gdata-gcontact-event.c
index da22afc..007fee6 100644
--- a/gdata/gcontact/gdata-gcontact-event.c
+++ b/gdata/gcontact/gdata-gcontact-event.c
@@ -278,7 +278,7 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
GDataGContactEventPrivate *priv = GDATA_GCONTACT_EVENT (parsable)->priv;
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 d9bc380..58b981e 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -2946,6 +2946,45 @@ test_gcontact_event_error_handling (void)
}
static void
+test_gcontact_event_escaping (void)
+{
+ GDataGContactEvent *event;
+ gchar *xml;
+ GDate date;
+
+ g_date_clear (&date, 1);
+ g_date_set_dmy (&date, 1, G_DATE_JANUARY, 2011);
+
+ /* Test with rel */
+ event = gdata_gcontact_event_new (&date, "http://foo.com?foo&relation=bar", NULL);
+
+ /* 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'?>"
+ "<gContact:event xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
+ "xmlns:gContact='http://schemas.google.com/contact/2008' rel='http://foo.com?foo&relation=bar'>"
+ "<gd:when startTime='2011-01-01'/>"
+ "</gContact:event>");
+ g_free (xml);
+ g_object_unref (event);
+
+ /* Test with label */
+ event = gdata_gcontact_event_new (&date, NULL, "Label & stuff");
+
+ /* 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'?>"
+ "<gContact:event xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
+ "xmlns:gContact='http://schemas.google.com/contact/2008' label='Label & stuff'>"
+ "<gd:when startTime='2011-01-01'/>"
+ "</gContact:event>");
+ g_free (xml);
+ g_object_unref (event);
+}
+
+static void
test_gcontact_external_id (void)
{
GDataGContactExternalID *id, *id2;
@@ -3412,6 +3451,7 @@ main (int argc, char *argv[])
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/event/escaping", test_gcontact_event_escaping);
g_test_add_func ("/gcontact/external_id", test_gcontact_external_id);
g_test_add_func ("/gcontact/external_id/error_handling", test_gcontact_external_id_error_handling);
g_test_add_func ("/gcontact/jot", test_gcontact_jot);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]