[libgdata] gcontact: Fix attribute escaping for GDataGContactExternalID
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] gcontact: Fix attribute escaping for GDataGContactExternalID
- Date: Thu, 2 Dec 2010 12:24:12 +0000 (UTC)
commit db01acd110abb30bbce46d9e6d922a1947c84ef9
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Dec 2 12:12:11 2010 +0000
gcontact: Fix attribute escaping for GDataGContactExternalID
Helps: bgo#631033
gdata/gcontact/gdata-gcontact-external-id.c | 2 +-
gdata/tests/general.c | 32 +++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/gdata/gcontact/gdata-gcontact-external-id.c b/gdata/gcontact/gdata-gcontact-external-id.c
index 8d26751..fd74dd1 100644
--- a/gdata/gcontact/gdata-gcontact-external-id.c
+++ b/gdata/gcontact/gdata-gcontact-external-id.c
@@ -249,7 +249,7 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
gdata_parser_string_append_escaped (xml_string, " value='", priv->value, "'");
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 58b981e..662cf2b 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -3066,6 +3066,37 @@ test_gcontact_external_id_error_handling (void)
}
static void
+test_gcontact_external_id_escaping (void)
+{
+ GDataGContactExternalID *id;
+ gchar *xml;
+
+ /* Test with rel */
+ id = gdata_gcontact_external_id_new ("<id>", "http://foo.com?foo&relation=bar", NULL);
+
+ /* Check the outputted XML is escaped properly */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (id));
+ g_assert_cmpstr (xml, ==,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<gContact:externalId xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' "
+ "value='<id>' rel='http://foo.com?foo&relation=bar'/>");
+ g_free (xml);
+ g_object_unref (id);
+
+ /* Test with label */
+ id = gdata_gcontact_external_id_new ("<id>", NULL, "Label & stuff");
+
+ /* Check the outputted XML is escaped properly */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (id));
+ g_assert_cmpstr (xml, ==,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<gContact:externalId xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' "
+ "value='<id>' label='Label & stuff'/>");
+ g_free (xml);
+ g_object_unref (id);
+}
+
+static void
test_gcontact_jot (void)
{
GDataGContactJot *jot, *jot2;
@@ -3454,6 +3485,7 @@ main (int argc, char *argv[])
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/external_id/escaping", test_gcontact_external_id_escaping);
g_test_add_func ("/gcontact/jot", test_gcontact_jot);
g_test_add_func ("/gcontact/jot/error_handling", test_gcontact_jot_error_handling);
g_test_add_func ("/gcontact/language", test_gcontact_language);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]