[libgdata] gcontact: Fix attribute escaping for GDataGContactWebsite
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] gcontact: Fix attribute escaping for GDataGContactWebsite
- Date: Thu, 2 Dec 2010 12:24:33 +0000 (UTC)
commit 0e59d4caf5463d846322f240431128df0fddc771
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Dec 2 12:23:42 2010 +0000
gcontact: Fix attribute escaping for GDataGContactWebsite
Helps: bgo#631033
gdata/gcontact/gdata-gcontact-website.c | 2 +-
gdata/tests/general.c | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/gdata/gcontact/gdata-gcontact-website.c b/gdata/gcontact/gdata-gcontact-website.c
index f1cd14d..de14948 100644
--- a/gdata/gcontact/gdata-gcontact-website.c
+++ b/gdata/gcontact/gdata-gcontact-website.c
@@ -268,7 +268,7 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
GDataGContactWebsitePrivate *priv = GDATA_GCONTACT_WEBSITE (parsable)->priv;
gdata_parser_string_append_escaped (xml_string, " href='", priv->uri, "'");
- g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
+ gdata_parser_string_append_escaped (xml_string, " rel='", priv->relation_type, "'");
if (priv->label != NULL)
gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
diff --git a/gdata/tests/general.c b/gdata/tests/general.c
index 84e7039..e49c5ba 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -3488,6 +3488,25 @@ test_gcontact_website_error_handling (void)
#undef TEST_XML_ERROR_HANDLING
}
+static void
+test_gcontact_website_escaping (void)
+{
+ GDataGContactWebsite *website;
+ gchar *xml;
+
+ website = gdata_gcontact_website_new ("http://foo.com?foo&bar", "http://foo.com?foo&relation=bar", "Label & stuff", TRUE);
+
+ /* Check the outputted XML is escaped properly */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (website));
+ g_assert_cmpstr (xml, ==,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<gContact:website 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' label='Label & stuff' "
+ "primary='true'/>");
+ g_free (xml);
+ g_object_unref (website);
+}
+
int
main (int argc, char *argv[])
{
@@ -3577,6 +3596,7 @@ main (int argc, char *argv[])
g_test_add_func ("/gcontact/relation/escaping", test_gcontact_relation_escaping);
g_test_add_func ("/gcontact/website", test_gcontact_website);
g_test_add_func ("/gcontact/website/error_handling", test_gcontact_website_error_handling);
+ g_test_add_func ("/gcontact/website/escaping", test_gcontact_website_escaping);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]