[libgdata] media: Fix attribute escaping for GDataMediaCategory
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] media: Fix attribute escaping for GDataMediaCategory
- Date: Thu, 2 Dec 2010 15:37:36 +0000 (UTC)
commit 435d9a9b250e9e81f454912e344b5e4b7707c33c
Author: Philip Withnall <philip tecnocode co uk>
Date: Thu Dec 2 15:30:51 2010 +0000
media: Fix attribute escaping for GDataMediaCategory
Helps: bgo#631033
gdata/media/gdata-media-category.c | 2 +-
gdata/tests/general.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/gdata/media/gdata-media-category.c b/gdata/media/gdata-media-category.c
index 9ca0b69..8f7fa41 100644
--- a/gdata/media/gdata-media-category.c
+++ b/gdata/media/gdata-media-category.c
@@ -234,7 +234,7 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
GDataMediaCategoryPrivate *priv = GDATA_MEDIA_CATEGORY (parsable)->priv;
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 e49c5ba..a1f98cf 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -2477,6 +2477,24 @@ test_media_category (void)
}
static void
+test_media_category_escaping (void)
+{
+ GDataMediaCategory *category;
+ gchar *xml;
+
+ category = gdata_media_category_new ("<category>", "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'?>"
+ "<media:category xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' "
+ "scheme='http://foo.com?foo&bar' label='Label & stuff'><category></media:category>");
+ g_free (xml);
+ g_object_unref (category);
+}
+
+static void
test_media_content (void)
{
GDataMediaContent *content;
@@ -3569,6 +3587,7 @@ main (int argc, char *argv[])
g_test_add_func ("/gd/who/escaping", test_gd_who_escaping);
g_test_add_func ("/media/category", test_media_category);
+ g_test_add_func ("/media/category/escaping", test_media_category_escaping);
g_test_add_func ("/media/content", test_media_content);
g_test_add_func ("/media/credit", test_media_credit);
/* g_test_add_func ("/media/group", test_media_group); */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]