[libgdata] atom: Fix attribute escaping for GDataLink
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] atom: Fix attribute escaping for GDataLink
- Date: Thu, 2 Dec 2010 11:54:06 +0000 (UTC)
commit 852579001a8e76c4cb5b5413429342dd643647f5
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Dec 2 11:53:27 2010 +0000
atom: Fix attribute escaping for GDataLink
Helps: bgo#631033
gdata/atom/gdata-link.c | 6 +++---
gdata/tests/general.c | 23 +++++++++++++++++++++++
2 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/gdata/atom/gdata-link.c b/gdata/atom/gdata-link.c
index 163beda..5c927e6 100644
--- a/gdata/atom/gdata-link.c
+++ b/gdata/atom/gdata-link.c
@@ -345,11 +345,11 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
if (priv->title != NULL)
gdata_parser_string_append_escaped (xml_string, " title='", priv->title, "'");
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, "'");
if (priv->content_type != NULL)
- g_string_append_printf (xml_string, " type='%s'", priv->content_type);
+ gdata_parser_string_append_escaped (xml_string, " type='", priv->content_type, "'");
if (priv->language != NULL)
- g_string_append_printf (xml_string, " hreflang='%s'", priv->language);
+ gdata_parser_string_append_escaped (xml_string, " hreflang='", priv->language, "'");
if (priv->length != -1)
g_string_append_printf (xml_string, " length='%i'", priv->length);
}
diff --git a/gdata/tests/general.c b/gdata/tests/general.c
index 061f2a8..c16caa3 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -1399,6 +1399,28 @@ test_atom_link_error_handling (void)
}
static void
+test_atom_link_escaping (void)
+{
+ GDataLink *_link;
+ gchar *xml;
+
+ _link = gdata_link_new ("http://foo.com?foo&bar", "http://foo.com?foo&relation=bar");
+ gdata_link_set_content_type (_link, "<content type>");
+ gdata_link_set_language (_link, "<language>");
+ gdata_link_set_title (_link, "Title & stuff");
+
+
+ /* Check the outputted XML is escaped properly */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (_link));
+ g_assert_cmpstr (xml, ==,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<link xmlns='http://www.w3.org/2005/Atom' href='http://foo.com?foo&bar' title='Title & stuff' "
+ "rel='http://foo.com?foo&relation=bar' type='<content type>' hreflang='<language>'/>");
+ g_free (xml);
+ g_object_unref (_link);
+}
+
+static void
test_app_categories (void)
{
GDataAPPCategories *categories;
@@ -3322,6 +3344,7 @@ main (int argc, char *argv[])
g_test_add_func ("/atom/generator/error_handling", test_atom_generator_error_handling);
g_test_add_func ("/atom/link", test_atom_link);
g_test_add_func ("/atom/link/error_handling", test_atom_link_error_handling);
+ g_test_add_func ("/atom/link/escaping", test_atom_link_escaping);
g_test_add_func ("/app/categories", test_app_categories);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]