[libgdata] atom: Fix attribute escaping for GDataCategory
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] atom: Fix attribute escaping for GDataCategory
- Date: Thu, 2 Dec 2010 11:54:01 +0000 (UTC)
commit 47e85e0de0094fc161aa9ab4b53f23b64feecde8
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Dec 2 11:47:41 2010 +0000
atom: Fix attribute escaping for GDataCategory
Helps: bgo#631033
gdata/atom/gdata-category.c | 4 ++--
gdata/tests/general.c | 19 +++++++++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/gdata/atom/gdata-category.c b/gdata/atom/gdata-category.c
index 57502c1..87c5603 100644
--- a/gdata/atom/gdata-category.c
+++ b/gdata/atom/gdata-category.c
@@ -226,10 +226,10 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
{
GDataCategoryPrivate *priv = GDATA_CATEGORY (parsable)->priv;
- g_string_append_printf (xml_string, " term='%s'", priv->term);
+ gdata_parser_string_append_escaped (xml_string, " term='", priv->term, "'");
if (priv->scheme != NULL)
- g_string_append_printf (xml_string, " scheme='%s'", priv->scheme);
+ gdata_parser_string_append_escaped (xml_string, " scheme='", priv->scheme, "'");
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 0c56fb1..061f2a8 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -1174,6 +1174,24 @@ test_atom_category_error_handling (void)
}
static void
+test_atom_category_escaping (void)
+{
+ GDataCategory *category;
+ gchar *xml;
+
+ category = gdata_category_new ("<term>", "http://foo.com?foo&bar", "Label & Stuff");
+
+ /* Check the outputted XML is escaped properly */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (category));
+ g_assert_cmpstr (xml, ==,
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<category xmlns='http://www.w3.org/2005/Atom' term='<term>' scheme='http://foo.com?foo&bar' "
+ "label='Label & Stuff'/>");
+ g_free (xml);
+ g_object_unref (category);
+}
+
+static void
test_atom_generator (void)
{
GDataGenerator *generator, *generator2;
@@ -3299,6 +3317,7 @@ main (int argc, char *argv[])
g_test_add_func ("/atom/author/escaping", test_atom_author_escaping);
g_test_add_func ("/atom/category", test_atom_category);
g_test_add_func ("/atom/category/error_handling", test_atom_category_error_handling);
+ g_test_add_func ("/atom/category/escaping", test_atom_category_escaping);
g_test_add_func ("/atom/generator", test_atom_generator);
g_test_add_func ("/atom/generator/error_handling", test_atom_generator_error_handling);
g_test_add_func ("/atom/link", test_atom_link);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]